svn commit: samba r16460 - in branches/tmp/vl-messaging/source/lib: .

ab at samba.org ab at samba.org
Thu Jun 22 13:24:00 GMT 2006


Author: ab
Date: 2006-06-22 13:24:00 +0000 (Thu, 22 Jun 2006)
New Revision: 16460

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16460

Log:
Finish TODO item for remote address checking and fix little glitches while in the same file
Modified:
   branches/tmp/vl-messaging/source/lib/messages_stream.c


Changeset:
Modified: branches/tmp/vl-messaging/source/lib/messages_stream.c
===================================================================
--- branches/tmp/vl-messaging/source/lib/messages_stream.c	2006-06-22 13:07:13 UTC (rev 16459)
+++ branches/tmp/vl-messaging/source/lib/messages_stream.c	2006-06-22 13:24:00 UTC (rev 16460)
@@ -214,10 +214,35 @@
 ****************************************************************************/
 
 #ifdef WITH_CLUSTERWIDE_MESSAGING
+#define ALLONES  ((uint32)0xFFFFFFFF)
+#define MKNETADDR(_IP, _NM) ((_IP) & (_NM))
 static BOOL remote_address_allowed(struct sockaddr_in* addr)
 {
-	/* TODO */
-	return True;
+	struct in_addr ip, nmask;
+	char *token = SMB_STRDUP(lp_messaging_network()), *p;
+
+	p = strchr_m(token,'/');
+	if (p == NULL) {
+		ip = *interpret_addr2(token);
+		nmask.s_addr = ALLONES;
+	} else {
+		/* parse it into an IP address/netmasklength pair */
+		*p = 0;
+		ip = *interpret_addr2(token);
+		p++;
+
+		if (strlen(p) > 2) {
+			nmask = *interpret_addr2(p);
+		} else {
+			nmask.s_addr = htonl(((ALLONES >> atoi(p)) ^ ALLONES));
+		}
+	}
+
+	SAFE_FREE(token);
+	
+	/* check the address */
+	return (MKNETADDR(ip.s_addr, nmask.s_addr) == 
+			MKNETADDR(addr->sin_addr.s_addr, nmask.s_addr));
 }
 #endif
 
@@ -241,7 +266,7 @@
 
 	if (addr.sin_family != AF_INET) {
 		DEBUG(5, ("Expected AF_INET(%d) in accept, got %d\n",
-				  AF_UNIX, addr.sin_family));
+				  AF_INET, addr.sin_family));
 		close(fd);
 		return;
 	}
@@ -462,7 +487,7 @@
 													TALLOC_CTX *mem_ctx,
 													struct message_list *cnt)
 {
-	size_t len, to_read;
+	size_t len = 0, to_read;
 	ssize_t nread;
 	uint8_t *target;
 



More information about the samba-cvs mailing list