[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Fri Mar 19 08:19:02 UTC 2021


The branch, master has been updated
       via  cf0c773ca56 messaging: Fix receiving file descriptors
       via  72540222c22 lib: Properly return errno from open_socket_in()
       via  8e54ed5a9cf rpcclient: Enable ncalrpc: transport
       via  55dba99895f librpc: Simplify dcerpc_binding_dup() with common nomem handling
       via  2c6bd3c6ab2 mdfind: Use cli_rpc_pipe_open_noauth() in mdfind util
       via  0426f11bf0f rpcclient: Let rpc_pipe_open_ncalrpc() figure out the dst sock itself
       via  a8ab5ab5bc2 rpc_client: Factor out rpccli_epm_map_interface() from rpc_pipe_get_tcp_port()
       via  3ee8960a1ec rpcclient: No need to use an object id in epm_map
       via  87137e340cc rpcclient: Don't put a port into the epm_map request
       via  e5942a715ec rpcclient: Remove pipe_default_auth globals
      from  f1a72fc63df samba-tool: Add a gpo command for removing VGP Host Access Group Policy

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit cf0c773ca56e0ae1b3123997d7910e0e0e248184
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 21 18:33:58 2021 +0100

    messaging: Fix receiving file descriptors
    
    Don't close unconsumed file descriptors in messaging_recv_cb(). Via
    multiple registrations on different tevent contexts we might call
    messaging_recv_cb() multiple times: All but the first tevent context
    handled in the loop in msg_dgm_ref_recv() will not see file
    descriptors anymore, it will just get a -1, even if the first
    reference had no receiver interested in the fds.
    
    Change the API such that consumers can set the file descriptor to -1
    if it's consumed. If nobody wanted them, do the close where they were
    created via recvmsg, in messages_dgm.c.
    
    If you want multiple handlers to consume the file descriptors, you
    should dup() them in the filter function handed to
    messaging_filtered_read_send and save the duplicate in your private
    data for later consumption.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Fri Mar 19 08:18:26 UTC 2021 on sn-devel-184

commit 72540222c2290dc041fb01018de7febe44a4ac0d
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Feb 12 21:27:19 2021 +0100

    lib: Properly return errno from open_socket_in()
    
    Before this patch, open_socket_in() relied on quite a bit of code to
    not touch errno after for example socket() returned -1. Change this to
    explicitly save errno in "ret", such that a later DEBUG() with all its
    formatting code can mess it up.
    
    While there, remove the debuglevel parameter. I don't think this
    actually useful.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8e54ed5a9cfcf497a51fe4b72387f255b9b0fa5e
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 16 08:29:33 2021 +0100

    rpcclient: Enable ncalrpc: transport
    
    Best reviewed with "git show -b". Right now lsarpc in the nt4_dc
    environment is not available over ncalrpc, so instead of getusername
    we need to use epmlookup for the rpcclient tests
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 55dba99895f0e3ef9b3553e24b75b7575ce0fbc3
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 15 17:45:32 2021 +0100

    librpc: Simplify dcerpc_binding_dup() with common nomem handling
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2c6bd3c6ab2e59e33a3703948ae31648212090fe
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 15 17:27:21 2021 +0100

    mdfind: Use cli_rpc_pipe_open_noauth() in mdfind util
    
    For the better or worse, we have a wrapper for NCACN_NP
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0426f11bf0f719f4056704e309140d21b1bbf6a7
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Feb 8 16:21:03 2021 +0100

    rpcclient: Let rpc_pipe_open_ncalrpc() figure out the dst sock itself
    
    Let the epmapper take care of this, with "EPMAPPER" being the default
    socket that is connected for registration from ep_register()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a8ab5ab5bc2b127bdd4c1c0ba779d57d3a3e4135
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Feb 8 15:47:41 2021 +0100

    rpc_client: Factor out rpccli_epm_map_interface() from rpc_pipe_get_tcp_port()
    
    Make it usable for ncalrpc as well
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3ee8960a1ec69fe5ff5226b1d13e8b8bb9493939
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 26 16:23:10 2021 +0100

    rpcclient: No need to use an object id in epm_map
    
    The interface id we're looking for is listed as floor 0 in the
    map_tower argument.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 87137e340cc8c9999fc5ff55f405a825a59dc4b9
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 26 16:22:35 2021 +0100

    rpcclient: Don't put a port into the epm_map request
    
    That's what the server is supposed to fill in for us
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e5942a715ec0f4469512eb3bba972f898ae09830
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 15 14:51:30 2021 +0100

    rpcclient: Remove pipe_default_auth globals
    
    We have all information in the binding, we don't need those globals.
    
    In case you're looking for tests: We have the combinations in our
    blackbox.rpcclient test. They don't actually check whether we really
    do the transport wrapping that is announced, some manual wireshark
    inspection showed that this does what it's supposed to do. And it took
    a quite bit of tweaking in binding_get_auth_info() to make this
    survive "make test TESTS=blackbox.rpcclient".
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/messaging/messages_dgm.c           |  14 +
 librpc/rpc/binding.c                   |  24 +-
 source3/include/proto.h                |  10 +-
 source3/lib/messages.c                 |  36 +-
 source3/lib/util_sock.c                | 157 ++++-----
 source3/librpc/rpc/dcerpc_ep.c         |  11 -
 source3/nmbd/nmbd.c                    |  12 +-
 source3/nmbd/nmbd_subnetdb.c           |  63 ++--
 source3/rpc_client/cli_pipe.c          | 337 +++++++++++++------
 source3/rpc_client/cli_pipe.h          |   2 +-
 source3/rpc_server/rpc_sock_helper.c   |  17 +-
 source3/rpcclient/rpcclient.c          | 599 ++++++++++++++++++++-------------
 source3/script/tests/test_rpcclient.sh |   2 +-
 source3/selftest/tests.py              |  26 +-
 source3/smbd/server.c                  |  13 +-
 source3/utils/mdfind.c                 |   5 +-
 source3/utils/nmblookup.c              |  16 +-
 source3/utils/smbfilter.c              |   6 +-
 18 files changed, 818 insertions(+), 532 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/messaging/messages_dgm.c b/lib/messaging/messages_dgm.c
index 733cd19d3b8..ef065def4d9 100644
--- a/lib/messaging/messages_dgm.c
+++ b/lib/messaging/messages_dgm.c
@@ -1323,6 +1323,18 @@ static int messaging_dgm_in_msg_destructor(struct messaging_dgm_in_msg *m)
 	return 0;
 }
 
+static void messaging_dgm_close_unconsumed(int *fds, size_t num_fds)
+{
+	size_t i;
+
+	for (i=0; i<num_fds; i++) {
+		if (fds[i] != -1) {
+			close(fds[i]);
+			fds[i] = -1;
+		}
+	}
+}
+
 /*
  * Deal with identification of fragmented messages and
  * re-assembly into full messages sent, then calls the
@@ -1349,6 +1361,7 @@ static void messaging_dgm_recv(struct messaging_dgm_context *ctx,
 	if (cookie == 0) {
 		ctx->recv_cb(ev, buf, buflen, fds, num_fds,
 			     ctx->recv_cb_private_data);
+		messaging_dgm_close_unconsumed(fds, num_fds);
 		return;
 	}
 
@@ -1412,6 +1425,7 @@ static void messaging_dgm_recv(struct messaging_dgm_context *ctx,
 
 	ctx->recv_cb(ev, msg->buf, msg->msglen, fds, num_fds,
 		     ctx->recv_cb_private_data);
+	messaging_dgm_close_unconsumed(fds, num_fds);
 
 	TALLOC_FREE(msg);
 	return;
diff --git a/librpc/rpc/binding.c b/librpc/rpc/binding.c
index 817498d8700..6588f43cc9d 100644
--- a/librpc/rpc/binding.c
+++ b/librpc/rpc/binding.c
@@ -1369,39 +1369,34 @@ _PUBLIC_ struct dcerpc_binding *dcerpc_binding_dup(TALLOC_CTX *mem_ctx,
 	if (b->object_string != NULL) {
 		n->object_string = talloc_strdup(n, b->object_string);
 		if (n->object_string == NULL) {
-			talloc_free(n);
-			return NULL;
+			goto nomem;
 		}
 	}
 	if (b->host != NULL) {
 		n->host = talloc_strdup(n, b->host);
 		if (n->host == NULL) {
-			talloc_free(n);
-			return NULL;
+			goto nomem;
 		}
 	}
 
 	if (b->target_hostname != NULL) {
 		n->target_hostname = talloc_strdup(n, b->target_hostname);
 		if (n->target_hostname == NULL) {
-			talloc_free(n);
-			return NULL;
+			goto nomem;
 		}
 	}
 
 	if (b->target_principal != NULL) {
 		n->target_principal = talloc_strdup(n, b->target_principal);
 		if (n->target_principal == NULL) {
-			talloc_free(n);
-			return NULL;
+			goto nomem;
 		}
 	}
 
 	if (b->endpoint != NULL) {
 		n->endpoint = talloc_strdup(n, b->endpoint);
 		if (n->endpoint == NULL) {
-			talloc_free(n);
-			return NULL;
+			goto nomem;
 		}
 	}
 
@@ -1412,21 +1407,22 @@ _PUBLIC_ struct dcerpc_binding *dcerpc_binding_dup(TALLOC_CTX *mem_ctx,
 
 		n->options = talloc_array(n, const char *, count + 1);
 		if (n->options == NULL) {
-			talloc_free(n);
-			return NULL;
+			goto nomem;
 		}
 
 		for (i = 0; i < count; i++) {
 			n->options[i] = talloc_strdup(n->options, b->options[i]);
 			if (n->options[i] == NULL) {
-				talloc_free(n);
-				return NULL;
+				goto nomem;
 			}
 		}
 		n->options[count] = NULL;
 	}
 
 	return n;
+nomem:
+	TALLOC_FREE(n);
+	return NULL;
 }
 
 _PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx,
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 1d5ebecb03c..dd262529212 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -515,11 +515,11 @@ NTSTATUS receive_smb_raw(int fd,
 			unsigned int timeout,
 			size_t maxlen,
 			size_t *p_len);
-int open_socket_in(int type,
-		uint16_t port,
-		int dlevel,
-		const struct sockaddr_storage *psock,
-		bool rebind);
+int open_socket_in(
+	int type,
+	const struct sockaddr_storage *paddr,
+	uint16_t port,
+	bool rebind);
 NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
 			 int timeout, int *pfd);
 struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index b63652ca1a5..8641a9dad56 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -396,21 +396,16 @@ static void messaging_recv_cb(struct tevent_context *ev,
 
 	if (msg_len < MESSAGE_HDR_LENGTH) {
 		DBG_WARNING("message too short: %zu\n", msg_len);
-		goto close_fail;
+		return;
 	}
 
 	if (num_fds > INT8_MAX) {
 		DBG_WARNING("too many fds: %zu\n", num_fds);
-		goto close_fail;
+		return;
 	}
 
-	/*
-	 * "consume" the fds by copying them and setting
-	 * the original variable to -1
-	 */
 	for (i=0; i < num_fds; i++) {
 		fds64[i] = fds[i];
-		fds[i] = -1;
 	}
 
 	rec = (struct messaging_rec) {
@@ -429,15 +424,13 @@ static void messaging_recv_cb(struct tevent_context *ev,
 
 	if (server_id_same_process(&rec.src, &msg_ctx->id)) {
 		DBG_DEBUG("Ignoring self-send\n");
-		goto close_fail;
+		return;
 	}
 
 	messaging_dispatch_rec(msg_ctx, ev, &rec);
-	return;
 
-close_fail:
-	for (i=0; i < num_fds; i++) {
-		close(fds[i]);
+	for (i=0; i<num_fds; i++) {
+		fds[i] = fds64[i];
 	}
 }
 
@@ -999,7 +992,16 @@ static struct messaging_rec *messaging_rec_dup(TALLOC_CTX *mem_ctx,
 
 	result->fds = NULL;
 	if (result->num_fds > 0) {
+		size_t i;
+
 		result->fds = talloc_memdup(result, rec->fds, fds_size);
+
+		for (i=0; i<rec->num_fds; i++) {
+			/*
+			 * fd's can only exist once
+			 */
+			rec->fds[i] = -1;
+		}
 	}
 
 	return result;
@@ -1395,16 +1397,6 @@ static void messaging_dispatch_rec(struct messaging_context *msg_ctx,
 			return;
 		}
 	}
-
-	/*
-	 * If the fd-array isn't used, just close it.
-	 */
-	for (i=0; i < rec->num_fds; i++) {
-		int fd = rec->fds[i];
-		close(fd);
-	}
-	rec->num_fds = 0;
-	rec->fds = NULL;
 }
 
 static int mess_parent_dgm_cleanup(void *private_data);
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 97415011097..2dbb572a974 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -234,67 +234,59 @@ NTSTATUS receive_smb_raw(int fd, char *buffer, size_t buflen, unsigned int timeo
 	return NT_STATUS_OK;
 }
 
-/****************************************************************************
- Open a socket of the specified type, port, and address for incoming data.
-****************************************************************************/
-
-int open_socket_in(int type,
-		uint16_t port,
-		int dlevel,
-		const struct sockaddr_storage *psock,
-		bool rebind)
+/*
+ * Open a socket of the specified type, port, and address for incoming data.
+ *
+ * Return sock or -errno
+ */
+
+int open_socket_in(
+	int type,
+	const struct sockaddr_storage *paddr,
+	uint16_t port,
+	bool rebind)
 {
-	struct sockaddr_storage sock;
-	int res;
-	socklen_t slen = sizeof(struct sockaddr_in);
-
-	sock = *psock;
+	struct samba_sockaddr addr = {
+		.sa_socklen = sizeof(struct sockaddr_storage),
+		.u.ss = *paddr,
+	};
+	int ret, sock = -1;
+	int val = rebind ? 1 : 0;
+	bool ok;
 
-#if defined(HAVE_IPV6)
-	if (sock.ss_family == AF_INET6) {
-		((struct sockaddr_in6 *)&sock)->sin6_port = htons(port);
-		slen = sizeof(struct sockaddr_in6);
+	ok = samba_sockaddr_set_port(&addr, port);
+	if (!ok) {
+		ret = -EINVAL;
+		DBG_DEBUG("samba_sockaddr_set_port failed\n");
+		goto fail;
 	}
-#endif
-	if (sock.ss_family == AF_INET) {
-		((struct sockaddr_in *)&sock)->sin_port = htons(port);
+
+	sock = socket(addr.u.ss.ss_family, type, 0 );
+	if (sock == -1) {
+		ret = -errno;
+		DBG_DEBUG("socket() failed: %s\n", strerror(errno));
+		goto fail;
 	}
 
-	res = socket(sock.ss_family, type, 0 );
-	if( res == -1 ) {
-		if( DEBUGLVL(0) ) {
-			dbgtext( "open_socket_in(): socket() call failed: " );
-			dbgtext( "%s\n", strerror( errno ) );
-		}
-		return -1;
+	ret = setsockopt(
+		sock, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
+	if (ret == -1) {
+		ret = -errno;
+		DBG_DEBUG("setsockopt(SO_REUSEADDR) failed: %s\n",
+			  strerror(errno));
+		goto fail;
 	}
 
-	/* This block sets/clears the SO_REUSEADDR and possibly SO_REUSEPORT. */
-	{
-		int val = rebind ? 1 : 0;
-		if( setsockopt(res,SOL_SOCKET,SO_REUSEADDR,
-					(char *)&val,sizeof(val)) == -1 ) {
-			if( DEBUGLVL( dlevel ) ) {
-				dbgtext( "open_socket_in(): setsockopt: " );
-				dbgtext( "SO_REUSEADDR = %s ",
-						val?"true":"false" );
-				dbgtext( "on port %d failed ", port );
-				dbgtext( "with error = %s\n", strerror(errno) );
-			}
-		}
 #ifdef SO_REUSEPORT
-		if( setsockopt(res,SOL_SOCKET,SO_REUSEPORT,
-					(char *)&val,sizeof(val)) == -1 ) {
-			if( DEBUGLVL( dlevel ) ) {
-				dbgtext( "open_socket_in(): setsockopt: ");
-				dbgtext( "SO_REUSEPORT = %s ",
-						val?"true":"false");
-				dbgtext( "on port %d failed ", port);
-				dbgtext( "with error = %s\n", strerror(errno));
-			}
-		}
-#endif /* SO_REUSEPORT */
+	ret = setsockopt(
+		sock, SOL_SOCKET, SO_REUSEPORT, (char *)&val, sizeof(val));
+	if (ret == -1) {
+		ret = -errno;
+		DBG_DEBUG("setsockopt(SO_REUSEPORT) failed: %s\n",
+			  strerror(errno));
+		goto fail;
 	}
+#endif /* SO_REUSEPORT */
 
 #ifdef HAVE_IPV6
 	/*
@@ -305,41 +297,50 @@ int open_socket_in(int type,
 	 * and makes sure %I never resolves to a '::ffff:192.168.0.1'
 	 * string.
 	 */
-	if (sock.ss_family == AF_INET6) {
-		int val = 1;
-		int ret;
+	if (addr.u.ss.ss_family == AF_INET6) {
+
+		val = 1;
 
-		ret = setsockopt(res, IPPROTO_IPV6, IPV6_V6ONLY,
-				 (const void *)&val, sizeof(val));
+		ret = setsockopt(
+			sock,
+			IPPROTO_IPV6,
+			IPV6_V6ONLY,
+			(const void *)&val,
+			sizeof(val));
 		if (ret == -1) {
-			if(DEBUGLVL(0)) {
-				dbgtext("open_socket_in(): IPV6_ONLY failed: ");
-				dbgtext("%s\n", strerror(errno));
-			}
-			close(res);
-			return -1;
+			ret = -errno;
+			DBG_DEBUG("setsockopt(IPV6_V6ONLY) failed: %s\n",
+				  strerror(errno));
+			goto fail;
 		}
 	}
 #endif
 
 	/* now we've got a socket - we need to bind it */
-	if (bind(res, (struct sockaddr *)&sock, slen) == -1 ) {
-		if( DEBUGLVL(dlevel) && (port == NMB_PORT ||
-					 port == NBT_SMB_PORT ||
-					 port == TCP_SMB_PORT) ) {
-			char addr[INET6_ADDRSTRLEN];
-			print_sockaddr(addr, sizeof(addr),
-					&sock);
-			dbgtext( "bind failed on port %d ", port);
-			dbgtext( "socket_addr = %s.\n", addr);
-			dbgtext( "Error = %s\n", strerror(errno));
-		}
-		close(res);
-		return -1;
+	ret = bind(sock, &addr.u.sa, addr.sa_socklen);
+	if (ret == -1) {
+		char addrstr[INET6_ADDRSTRLEN];
+
+		ret = -errno;
+
+		print_sockaddr(addrstr, sizeof(addrstr), &addr.u.ss);
+		DBG_DEBUG("bind for %s port %"PRIu16" failed: %s\n",
+			  addrstr,
+			  port,
+			  strerror(-ret));
+		goto fail;
 	}
 
-	DEBUG( 10, ( "bind succeeded on port %d\n", port ) );
-	return( res );
+	DBG_DEBUG("bind succeeded on port %"PRIu16"\n", port);
+
+	return sock;
+
+fail:
+	if (sock != -1) {
+		close(sock);
+		sock = -1;
+	}
+	return ret;
  }
 
 struct open_socket_out_state {
diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c
index fec5f6ca1b7..66b8b975d75 100644
--- a/source3/librpc/rpc/dcerpc_ep.c
+++ b/source3/librpc/rpc/dcerpc_ep.c
@@ -44,7 +44,6 @@ static NTSTATUS ep_register(TALLOC_CTX *mem_ctx,
 	struct rpc_pipe_client *cli = NULL;
 	struct dcerpc_binding_handle *h;
 	struct pipe_auth_data *auth;
-	const char *ncalrpc_sock;
 	enum rpc_service_mode_e epmd_mode;
 	struct epm_entry_t *entries = NULL;
 	uint32_t i = 0;
@@ -115,17 +114,7 @@ static NTSTATUS ep_register(TALLOC_CTX *mem_ctx,
 		}
 	} else if (epmd_mode == RPC_SERVICE_MODE_EXTERNAL) {
 		/* Connect to the endpoint mapper locally */
-		ncalrpc_sock = talloc_asprintf(tmp_ctx,
-					      "%s/%s",
-					      lp_ncalrpc_dir(),
-					      "EPMAPPER");
-		if (ncalrpc_sock == NULL) {
-			status = NT_STATUS_NO_MEMORY;
-			goto done;
-		}
-
 		status = rpc_pipe_open_ncalrpc(tmp_ctx,
-					       ncalrpc_sock,
 					       &ndr_table_epmapper,
 					       &cli);
 		if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 1f7e81a5473..dce746a8339 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -733,22 +733,18 @@ static bool open_sockets(bool isdaemon, int port)
 	}
 
 	if (isdaemon) {
-		ClientNMB = open_socket_in(SOCK_DGRAM, port,
-					   0, &ss,
-					   true);
+		ClientNMB = open_socket_in(SOCK_DGRAM, &ss, port, true);
 	} else {
 		ClientNMB = 0;
 	}
 
-	if (ClientNMB == -1) {
+	if (ClientNMB < 0) {
 		return false;
 	}
 
-	ClientDGRAM = open_socket_in(SOCK_DGRAM, DGRAM_PORT,
-					   3, &ss,
-					   true);
+	ClientDGRAM = open_socket_in(SOCK_DGRAM, &ss, DGRAM_PORT, true);
 
-	if (ClientDGRAM == -1) {
+	if (ClientDGRAM < 0) {
 		if (ClientNMB != 0) {
 			close(ClientNMB);
 		}
diff --git a/source3/nmbd/nmbd_subnetdb.c b/source3/nmbd/nmbd_subnetdb.c
index 5c9e4c7eb26..38c6db69b3d 100644
--- a/source3/nmbd/nmbd_subnetdb.c
+++ b/source3/nmbd/nmbd_subnetdb.c
@@ -107,56 +107,55 @@ static struct subnet_record *make_subnet(const char *name, enum subnet_type type
 		 * Fail the subnet creation if this fails.
 		 */
 
-		nmb_sock = open_socket_in(SOCK_DGRAM, global_nmb_port,
-					  0, &ss, true);
-		if (nmb_sock == -1) {
-			DEBUG(0,   ("nmbd_subnetdb:make_subnet()\n"));
-			DEBUGADD(0,("  Failed to open nmb socket on interface %s ",
-				    inet_ntoa(myip)));
-			DEBUGADD(0,("for port %d.  ", global_nmb_port));
-			DEBUGADD(0,("Error was %s\n", strerror(errno)));
+		nmb_sock = open_socket_in(
+			SOCK_DGRAM, &ss, global_nmb_port, true);
+		if (nmb_sock < 0) {
+			DBG_ERR("Failed to open nmb socket on interface %s "
+				"for port %d: %s\n",
+				inet_ntoa(myip),
+				global_nmb_port,
+				strerror(-nmb_sock));
 			goto failed;
 		}
 		set_socket_options(nmb_sock,"SO_BROADCAST");
 		set_blocking(nmb_sock, false);
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list