summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-01-16 14:01:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:12 -0500
commit044c570ea9348df6d6618bbef6dd4bc21a61d1ed (patch)
treecb86e83aceb579f7d2cd6aed3bd454a844d6c111
parenta45b4b7b99ed1fd93393ec770edace58502c6810 (diff)
downloadsamba-044c570ea9348df6d6618bbef6dd4bc21a61d1ed.tar.gz
samba-044c570ea9348df6d6618bbef6dd4bc21a61d1ed.tar.bz2
samba-044c570ea9348df6d6618bbef6dd4bc21a61d1ed.zip
r12958: don't bind to '255.255.255.255'
fix bug #3411 metze (This used to be commit 2cb587c779b5f70e4818fa57fcb2b8ee4a2a276b)
-rw-r--r--source4/nbt_server/dgram/request.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/source4/nbt_server/dgram/request.c b/source4/nbt_server/dgram/request.c
index 7a1f7c42d8..8dcd53b9b1 100644
--- a/source4/nbt_server/dgram/request.c
+++ b/source4/nbt_server/dgram/request.c
@@ -56,7 +56,7 @@ void dgram_request_handler(struct nbt_dgram_socket *dgmsock,
*/
NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address)
{
- struct nbt_dgram_socket *bcast_dgmsock;
+ struct nbt_dgram_socket *bcast_dgmsock = NULL;
struct nbtd_server *nbtsrv = iface->nbtsrv;
struct socket_address *bcast_addr, *bind_addr;
NTSTATUS status;
@@ -68,31 +68,31 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address
return NT_STATUS_NO_MEMORY;
}
- /* listen for broadcasts on port 138 */
- bcast_dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
- if (!bcast_dgmsock) {
- talloc_free(tmp_ctx);
- return NT_STATUS_NO_MEMORY;
- }
+ if (strcmp("0.0.0.0", iface->netmask) != 0) {
+ /* listen for broadcasts on port 138 */
+ bcast_dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
+ if (!bcast_dgmsock) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
- bcast_addr = socket_address_from_strings(tmp_ctx, bcast_dgmsock->sock->backend_name,
- iface->bcast_address,
- lp_dgram_port());
-
- status = socket_listen(bcast_dgmsock->sock, bcast_addr, 0, 0);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(tmp_ctx);
- DEBUG(0,("Failed to bind to %s:%d - %s\n",
- iface->bcast_address, lp_dgram_port(), nt_errstr(status)));
- return status;
- }
- talloc_free(bcast_addr);
+ bcast_addr = socket_address_from_strings(tmp_ctx, bcast_dgmsock->sock->backend_name,
+ iface->bcast_address, lp_dgram_port());
+ if (!bcast_addr) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = socket_listen(bcast_dgmsock->sock, bcast_addr, 0, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ DEBUG(0,("Failed to bind to %s:%d - %s\n",
+ iface->bcast_address, lp_dgram_port(), nt_errstr(status)));
+ return status;
+ }
- dgram_set_incoming_handler(bcast_dgmsock, dgram_request_handler, iface);
-
- bind_addr = socket_address_from_strings(tmp_ctx, bcast_dgmsock->sock->backend_name,
- bind_address,
- lp_dgram_port());
+ dgram_set_incoming_handler(bcast_dgmsock, dgram_request_handler, iface);
+ }
/* listen for unicasts on port 138 */
iface->dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
@@ -101,6 +101,13 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address
return NT_STATUS_NO_MEMORY;
}
+ bind_addr = socket_address_from_strings(tmp_ctx, iface->dgmsock->sock->backend_name,
+ bind_address, lp_dgram_port());
+ if (!bind_addr) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
status = socket_listen(iface->dgmsock->sock, bind_addr, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
@@ -108,23 +115,23 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address
bind_address, lp_dgram_port(), nt_errstr(status)));
return status;
}
- talloc_free(bind_addr);
dgram_set_incoming_handler(iface->dgmsock, dgram_request_handler, iface);
talloc_free(tmp_ctx);
-
for (i=0;i<ARRAY_SIZE(mailslot_handlers);i++) {
/* note that we don't need to keep the pointer
to the dgmslot around - the callback is all
we need */
struct dgram_mailslot_handler *dgmslot;
- dgmslot = dgram_mailslot_listen(bcast_dgmsock,
+ if (bcast_dgmsock) {
+ dgmslot = dgram_mailslot_listen(bcast_dgmsock,
mailslot_handlers[i].mailslot_name,
mailslot_handlers[i].handler, iface);
- NT_STATUS_HAVE_NO_MEMORY(dgmslot);
+ NT_STATUS_HAVE_NO_MEMORY(dgmslot);
+ }
dgmslot = dgram_mailslot_listen(iface->dgmsock,
mailslot_handlers[i].mailslot_name,