From 5297f3fcffbe42c646048abf63e63ed10d971d46 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 4 Jan 2011 17:58:12 +0100 Subject: [PATCH] s3: Make nmbd listen on the unexpected socket --- source3/nmbd/nmbd.c | 5 +++++ source3/nmbd/nmbd_packets.c | 20 ++++++++++++++++++++ source3/nmbd/nmbd_proto.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 30bbeaadee2..eaa5055998f 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -1017,6 +1017,11 @@ static bool open_sockets(bool isdaemon, int port) exit(1); } + if (!nmbd_init_packet_server()) { + kill_async_dns_child(); + exit(1); + } + TALLOC_FREE(frame); process(); diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c index 1e72c188882..ec5225a5eca 100644 --- a/source3/nmbd/nmbd_packets.c +++ b/source3/nmbd/nmbd_packets.c @@ -31,6 +31,22 @@ extern int num_response_packets; bool rescan_listen_set = False; +static struct nb_packet_server *packet_server; + +bool nmbd_init_packet_server(void) +{ + NTSTATUS status; + + status = nb_packet_server_create(NULL, nmbd_event_context(), 0, + &packet_server); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("ERROR: nb_packet_server_create failed: %s\n", + nt_errstr(status))); + return false; + } + return true; +} + /******************************************************************* The global packet linked-list. Incoming entries are @@ -1204,6 +1220,7 @@ static void process_dgram(struct packet_struct *p) /* If we aren't listening to the destination name then ignore the packet */ if (!listening(p,&dgram->dest_name)) { + nb_packet_dispatch(packet_server, p); unexpected_packet(p); DEBUG(5,("process_dgram: ignoring dgram packet sent to name %s from %s\n", nmb_namestr(&dgram->dest_name), inet_ntoa(p->ip))); @@ -1211,6 +1228,7 @@ static void process_dgram(struct packet_struct *p) } if (dgram->header.msg_type != 0x10 && dgram->header.msg_type != 0x11 && dgram->header.msg_type != 0x12) { + nb_packet_dispatch(packet_server, p); unexpected_packet(p); /* Don't process error packets etc yet */ DEBUG(5,("process_dgram: ignoring dgram packet sent to name %s from IP %s as it is \ @@ -1297,6 +1315,7 @@ packet sent to name %s from IP %s\n", return; } + nb_packet_dispatch(packet_server, p); unexpected_packet(p); } @@ -1417,6 +1436,7 @@ static struct subnet_record *find_subnet_for_nmb_packet( struct packet_struct *p if(rrec == NULL) { DEBUG(3,("find_subnet_for_nmb_packet: response record not found for response id %hu\n", nmb->header.name_trn_id)); + nb_packet_dispatch(packet_server, p); unexpected_packet(p); return NULL; } diff --git a/source3/nmbd/nmbd_proto.h b/source3/nmbd/nmbd_proto.h index e90a90ee7f1..b58ca41e5a0 100644 --- a/source3/nmbd/nmbd_proto.h +++ b/source3/nmbd/nmbd_proto.h @@ -173,6 +173,8 @@ bool node_status(struct subnet_record *subrec, struct nmb_name *nmbname, /* The following definitions come from nmbd/nmbd_packets.c */ +bool nmbd_init_packet_server(void); + uint16 get_nb_flags(char *buf); void set_nb_flags(char *buf, uint16 nb_flags); struct response_record *queue_register_name( struct subnet_record *subrec, -- 2.11.4.GIT