svn commit: lorikeet r651 - in trunk/heimdal/lib/roken: .

abartlet at samba.org abartlet at samba.org
Mon Nov 6 05:00:35 GMT 2006


Author: abartlet
Date: 2006-11-06 05:00:34 +0000 (Mon, 06 Nov 2006)
New Revision: 651

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

Log:
A few fixes to have Heimdal pass the make check under socket_wrapper.

The first is a missing 'break' before the (heimdal specific) IPv6 support.  

The second works around the fact that sendto() *may* object to a
destination being specified.  It appears to be that on Linux, this
objects (with EISCONN) for unix stream sockets, but not for TCP
sockets.

The alternate fix would be to have the KDC use 'send()' in this case.

Andrew Bartlett

Modified:
   trunk/heimdal/lib/roken/socket_wrapper.c


Changeset:
Modified: trunk/heimdal/lib/roken/socket_wrapper.c
===================================================================
--- trunk/heimdal/lib/roken/socket_wrapper.c	2006-11-06 00:41:47 UTC (rev 650)
+++ trunk/heimdal/lib/roken/socket_wrapper.c	2006-11-06 05:00:34 UTC (rev 651)
@@ -388,6 +388,7 @@
 			return -1;
 		}
 		if (bcast) *bcast = is_bcast;
+		break;
 	}
 #ifdef HAVE_IPV6
 	case AF_INET6: {
@@ -1673,38 +1674,45 @@
 		return real_sendto(s, buf, len, flags, to, tolen);
 	}
 
-	if (si->bound == 0) {
-		ret = swrap_auto_bind(si);
+	switch (si->type) {
+	case SOCK_STREAM:
+		ret = real_send(s, buf, len, flags);
+		break;
+	case SOCK_DGRAM:
+		if (si->bound == 0) {
+			ret = swrap_auto_bind(si);
+			if (ret == -1) return -1;
+		}
+		
+		ret = sockaddr_convert_to_un(si, to, tolen, &un_addr, 0, &bcast);
 		if (ret == -1) return -1;
-	}
-
-	ret = sockaddr_convert_to_un(si, to, tolen, &un_addr, 0, &bcast);
-	if (ret == -1) return -1;
-
-	if (bcast) {
-		struct stat st;
-		unsigned int iface;
-		unsigned int prt = ntohs(((const struct sockaddr_in *)to)->sin_port);
-		char type;
-
-		type = SOCKET_TYPE_CHAR_UDP;
-
-		for(iface=0; iface <= MAX_WRAPPED_INTERFACES; iface++) {
-			snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s/"SOCKET_FORMAT, 
-				 socket_wrapper_dir(), type, iface, prt);
-			if (stat(un_addr.sun_path, &st) != 0) continue;
-
-			/* ignore the any errors in broadcast sends */
-			real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr));
+		
+		if (bcast) {
+			struct stat st;
+			unsigned int iface;
+			unsigned int prt = ntohs(((const struct sockaddr_in *)to)->sin_port);
+			char type;
+			
+			type = SOCKET_TYPE_CHAR_UDP;
+			
+			for(iface=0; iface <= MAX_WRAPPED_INTERFACES; iface++) {
+				snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s/"SOCKET_FORMAT, 
+					 socket_wrapper_dir(), type, iface, prt);
+				if (stat(un_addr.sun_path, &st) != 0) continue;
+				
+				/* ignore the any errors in broadcast sends */
+				real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr));
+			}
+			
+			swrap_dump_packet(si, to, SWRAP_SENDTO, buf, len);
+			
+			return len;
 		}
-
-		swrap_dump_packet(si, to, SWRAP_SENDTO, buf, len);
-
-		return len;
+		
+		ret = real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr));
+		break;
 	}
-
-	ret = real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr));
-
+		
 	/* to give better errors */
 	if (ret == -1 && errno == ENOENT) {
 		errno = EHOSTUNREACH;



More information about the samba-cvs mailing list