From e5c319186d079eeef55a7ee62fac2a993e932938 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 22 Oct 1997 11:02:00 +0000 Subject: Implemented asynchronous DNS lookups in nmbd. I realised this afternoon just how easy it is to add this, so I thought I'd implement it while the idea was fresh. nmbd forks at startup and uses a pipe to talk to its child. The child does the DNS lookups and the file descriptor of the child is added to the main select loop. While I was doing this I discovered a bug in nmbd that explains why the dns proxy option has been so expensive. The DNS cache entries in the WINS list were never being checked, which means we always did a DNS lookup even if we have done it before and it is in cache. I'm sure this used to work (I tested the DNS cache when I added it) so someone broke it :-( Anyway, the async DNS gets rid of the problem completely. I'll commit just the fix to the DNS cache bug to the 1.9.17 tree. You can disable async DNS by adding -DSYNC_DNS to the compile flags. (This used to be commit 178e27de0791c1ff3268cb456ed5c5efc9ac2a01) --- source3/nmbd/asyncdns.c | 257 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 source3/nmbd/asyncdns.c (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c new file mode 100644 index 0000000000..548781edea --- /dev/null +++ b/source3/nmbd/asyncdns.c @@ -0,0 +1,257 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + a async DNS handler + Copyright (C) Andrew Tridgell 1994-1997 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Revision History: + + 14 jan 96: lkcl@pires.co.uk + added multiple workgroup domain master support + +*/ + +#include "includes.h" + +extern int DEBUGLEVEL; + + +/*************************************************************************** + add a DNS result to the name cache + ****************************************************************************/ +static struct name_record *add_dns_result(struct nmb_name *question, struct in_addr addr) +{ + int name_type = question->name_type; + char *qname = question->name; + + if (!addr.s_addr) { + /* add the fail to WINS cache of names. give it 1 hour in the cache */ + DEBUG(3,("Negative DNS answer for %s\n", qname)); + add_netbios_entry(wins_subnet,qname,name_type,NB_ACTIVE,60*60,DNSFAIL,addr, + True, True); + return NULL; + } + + /* add it to our WINS cache of names. give it 2 hours in the cache */ + DEBUG(3,("DNS gave answer for %s of %s\n", qname, inet_ntoa(addr))); + + return add_netbios_entry(wins_subnet,qname,name_type,NB_ACTIVE,2*60*60,DNS,addr, + True,True); +} + + + +#ifndef SYNC_DNS + +static int fd_in = -1, fd_out = -1; +static int child_pid = -1; +static int in_dns; + +/* this is the structure that is passed between the parent and child */ +struct query_record { + struct nmb_name name; + struct in_addr result; +}; + +/* a queue of pending requests waiting for DNS responses */ +static struct packet_struct *dns_queue; + + + +/*************************************************************************** + return the fd used to gather async dns replies. This is added to the select + loop + ****************************************************************************/ +int asyncdns_fd(void) +{ + return fd_in; +} + +/*************************************************************************** + handle DNS queries arriving from the parent + ****************************************************************************/ +static void asyncdns_process(void) +{ + struct query_record r; + fstring qname; + + DEBUGLEVEL = 0; + + while (1) { + if (read_data(fd_in, (char *)&r, sizeof(r)) != sizeof(r)) + break; + + fstrcpy(qname, r.name.name); + + r.result.s_addr = interpret_addr(qname); + + if (write_data(fd_out, (char *)&r, sizeof(r)) != sizeof(r)) + break; + } + + exit(0); +} + + +/*************************************************************************** + create a child process to handle DNS lookups + ****************************************************************************/ +void start_async_dns(void) +{ + int fd1[2], fd2[2]; + + signal(SIGCLD, SIG_IGN); + + if (pipe(fd1) || pipe(fd2)) { + return; + } + + child_pid = fork(); + + if (child_pid) { + fd_in = fd1[0]; + fd_out = fd2[1]; + close(fd1[1]); + close(fd2[0]); + DEBUG(3,("async DNS initialised\n")); + return; + } + + fd_in = fd2[0]; + fd_out = fd1[1]; + + asyncdns_process(); +} + + +/*************************************************************************** +check if a particular name is already being queried + ****************************************************************************/ +static BOOL query_in_queue(struct query_record *r) +{ + struct packet_struct *p; + for (p = dns_queue; p; p = p->next) { + struct nmb_packet *nmb = &p->packet.nmb; + struct nmb_name *question = &nmb->question.question_name; + + if (name_equal(question, &r->name)) + return True; + } + return False; +} + + +/*************************************************************************** + check the DNS queue + ****************************************************************************/ +void run_dns_queue(void) +{ + struct query_record r; + struct packet_struct *p, *p2; + + if (fd_in == -1) + return; + + if (read_data(fd_in, (char *)&r, sizeof(r)) != sizeof(r)) { + DEBUG(0,("Incomplete DNS answer from child!\n")); + fd_in = -1; + return; + } + + add_dns_result(&r.name, r.result); + + /* loop over the whole dns queue looking for entries that + match the result we just got */ + for (p = dns_queue; p;) { + struct nmb_packet *nmb = &p->packet.nmb; + struct nmb_name *question = &nmb->question.question_name; + + if (name_equal(question, &r.name)) { + DEBUG(3,("DNS calling reply_name_query\n")); + in_dns = 1; + reply_name_query(p); + in_dns = 0; + p->locked = False; + + if (p->prev) + p->prev->next = p->next; + else + dns_queue = p->next; + if (p->next) + p->next->prev = p->prev; + p2 = p->next; + free_packet(p); + p = p2; + } else { + p = p->next; + } + } + +} + +/*************************************************************************** +queue a DNS query + ****************************************************************************/ +BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, + struct name_record **n) +{ + struct query_record r; + + if (in_dns || fd_in == -1) + return False; + + r.name = *question; + + if (!query_in_queue(&r) && + !write_data(fd_out, (char *)&r, sizeof(r))) { + DEBUG(3,("failed to send DNS query to child!\n")); + return False; + } + + p->locked = True; + p->next = dns_queue; + p->prev = NULL; + if (p->next) + p->next->prev = p; + dns_queue = p; + + + DEBUG(3,("added DNS query for %s\n", namestr(question))); + return True; +} + +#else + + +/*************************************************************************** + we use this then we can't do async DNS lookups + ****************************************************************************/ +BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, + struct name_record **n) +{ + int name_type = question->name_type; + char *qname = question->name; + struct in_addr dns_ip; + + DEBUG(3,("DNS search for %s - ", namestr(question))); + + dns_ip.s_addr = interpret_addr(qname); + + *n = add_dns_result(question, dns_ip); + return False; +} +#endif -- cgit From abb255cfe674a39c6a42f5083af9c5facdbcca05 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 23 Oct 1997 22:30:57 +0000 Subject: Big change to make nmbd code more readable/understandable. Main change is removal of find_name_search() confusion. This has been replaced with find_name_on_subnet() which makes it explicit what is being searched. Also changed wins_subnet to be wins_client_subnet in preparation for splitting the wins subnet into client and server pieces. This is a big nmbd change and I'd appreciate any bug reports. Specific changes follow : asyncdns.c: Removed wins entry from add_netbios_entry(). This is now explicit in the subnet_record parameter. interface.c: iface_bcast(), iface_nmask(), iface_ip() return the default interface if none can be found. Made this behavior explicit - some code in nmbd incorrectly depended upon this (reply_name_status() for instance). nameannounce.c: find_name_search changes to find_name_on_subnet. namebrowse.c: wins_subnet renamed to wins_client_subnet. namedbname.c: find_name_search removed. find_name_on_subnet added. add_netbios_entry - wins parameter removed. namedbsubnet.c: find_req_subnet removed - not explicit enough. nameelect.c: wins_subnet renamed to wins_client_subnet. namepacket.c: listening() simplified. nameresp.c: wins_subnet renamed to wins_client_subnet. nameserv.c: find_name_search moved to find_name_on_subnet. nameserv.h: FIND_XXX -> changed to FIND_SELF_NAME, FIND_ANY_NAME. nameservreply.c: find_name_search moved to find_name_on_subnet. Debug entries changed. nameservresp.c: wins_subnet renamed to wins_client_subnet. namework.c: wins_subnet renamed to wins_client_subnet. nmbd.c: wins parameter removed from add_netbios_entry. nmbsync: wins_subnet renamed to wins_client_subnet. proto.h: The usual. server.c: remove accepted fd from fd_set. Jeremy (jallison@whistle.com) (This used to be commit 2c97b33fc0b5ef181dbf51a50cb61074935165bf) --- source3/nmbd/asyncdns.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 548781edea..94fd65b147 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -35,22 +35,22 @@ extern int DEBUGLEVEL; ****************************************************************************/ static struct name_record *add_dns_result(struct nmb_name *question, struct in_addr addr) { - int name_type = question->name_type; - char *qname = question->name; - - if (!addr.s_addr) { - /* add the fail to WINS cache of names. give it 1 hour in the cache */ - DEBUG(3,("Negative DNS answer for %s\n", qname)); - add_netbios_entry(wins_subnet,qname,name_type,NB_ACTIVE,60*60,DNSFAIL,addr, - True, True); - return NULL; - } - - /* add it to our WINS cache of names. give it 2 hours in the cache */ - DEBUG(3,("DNS gave answer for %s of %s\n", qname, inet_ntoa(addr))); - - return add_netbios_entry(wins_subnet,qname,name_type,NB_ACTIVE,2*60*60,DNS,addr, - True,True); + int name_type = question->name_type; + char *qname = question->name; + + if (!addr.s_addr) { + /* add the fail to WINS cache of names. give it 1 hour in the cache */ + DEBUG(3,("Negative DNS answer for %s\n", qname)); + add_netbios_entry(wins_client_subnet,qname,name_type,NB_ACTIVE,60*60, + DNSFAIL,addr,True); + return NULL; + } + + /* add it to our WINS cache of names. give it 2 hours in the cache */ + DEBUG(3,("DNS gave answer for %s of %s\n", qname, inet_ntoa(addr))); + + return add_netbios_entry(wins_client_subnet,qname,name_type,NB_ACTIVE, + 2*60*60,DNS,addr, True); } -- cgit From 87cada5fd33ea26cccb72454f97781e6e6c3254d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 1 Nov 1997 23:42:28 +0000 Subject: minor async DNS cleanups - start it earlier - set DEBUGLEVEL to -1 to prevent any debug calls in child - exit with _exit() to prevent logfile corruption (This used to be commit 21dd073a2003fa4707c1577a6b07bcef30eb6a50) --- source3/nmbd/asyncdns.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 94fd65b147..4982f7f340 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -89,7 +89,7 @@ static void asyncdns_process(void) struct query_record r; fstring qname; - DEBUGLEVEL = 0; + DEBUGLEVEL = -1; while (1) { if (read_data(fd_in, (char *)&r, sizeof(r)) != sizeof(r)) @@ -103,7 +103,7 @@ static void asyncdns_process(void) break; } - exit(0); + _exit(0); } @@ -127,7 +127,6 @@ void start_async_dns(void) fd_out = fd2[1]; close(fd1[1]); close(fd2[0]); - DEBUG(3,("async DNS initialised\n")); return; } -- cgit From 4fe3b2ce751806e2add9c021c60c22d22fedbab5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Nov 1997 01:25:50 +0000 Subject: to avoid any possibility of the pipe getting full and blocking we now only allow one query in the async dns pipe at a time. The others are queued in the parent. (This used to be commit f1004dd52adb29d088f0725e2c940ed44d3a764f) --- source3/nmbd/asyncdns.c | 85 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 27 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 4982f7f340..a451f6b617 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -67,9 +67,11 @@ struct query_record { struct in_addr result; }; -/* a queue of pending requests waiting for DNS responses */ +/* a queue of pending requests waiting to be sent to the DNS child */ static struct packet_struct *dns_queue; +/* the packet currently being processed by the dns child */ +static struct packet_struct *dns_current; /*************************************************************************** @@ -140,20 +142,26 @@ void start_async_dns(void) /*************************************************************************** check if a particular name is already being queried ****************************************************************************/ -static BOOL query_in_queue(struct query_record *r) +static BOOL query_current(struct query_record *r) { - struct packet_struct *p; - for (p = dns_queue; p; p = p->next) { - struct nmb_packet *nmb = &p->packet.nmb; - struct nmb_name *question = &nmb->question.question_name; - - if (name_equal(question, &r->name)) - return True; - } - return False; + return dns_current && + name_equal(&r->name, + &dns_current->packet.nmb.question.question_name); } +/*************************************************************************** + write a query to the child process + ****************************************************************************/ +static BOOL write_child(struct packet_struct *p) +{ + struct query_record r; + + r.name = p->packet.nmb.question.question_name; + + return write_data(fd_out, (char *)&r, sizeof(r)) == sizeof(r); +} + /*************************************************************************** check the DNS queue ****************************************************************************/ @@ -173,6 +181,19 @@ void run_dns_queue(void) add_dns_result(&r.name, r.result); + if (dns_current) { + if (query_current(&r)) { + DEBUG(3,("DNS calling reply_name_query\n")); + in_dns = 1; + reply_name_query(dns_current); + in_dns = 0; + } + + dns_current->locked = False; + free_packet(dns_current); + dns_current = NULL; + } + /* loop over the whole dns queue looking for entries that match the result we just got */ for (p = dns_queue; p;) { @@ -200,6 +221,18 @@ void run_dns_queue(void) } } + if (dns_queue) { + dns_current = dns_queue; + dns_queue = dns_queue->next; + if (dns_queue) dns_queue->prev = NULL; + dns_current->next = NULL; + + if (!write_child(dns_current)) { + DEBUG(3,("failed to send DNS query to child!\n")); + return; + } + } + } /*************************************************************************** @@ -208,27 +241,25 @@ queue a DNS query BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, struct name_record **n) { - struct query_record r; - if (in_dns || fd_in == -1) return False; - r.name = *question; - - if (!query_in_queue(&r) && - !write_data(fd_out, (char *)&r, sizeof(r))) { - DEBUG(3,("failed to send DNS query to child!\n")); - return False; + if (!dns_current) { + if (!write_child(p)) { + DEBUG(3,("failed to send DNS query to child!\n")); + return False; + } + dns_current = p; + p->locked = True; + } else { + p->locked = True; + p->next = dns_queue; + p->prev = NULL; + if (p->next) + p->next->prev = p; + dns_queue = p; } - p->locked = True; - p->next = dns_queue; - p->prev = NULL; - if (p->next) - p->next->prev = p; - dns_queue = p; - - DEBUG(3,("added DNS query for %s\n", namestr(question))); return True; } -- cgit From d186100b661607e8f02274f03334dbd10f6df39d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Nov 1997 01:33:28 +0000 Subject: fix comments (This used to be commit b3fd976b6c5c8342d04d87a7523864b09918d260) --- source3/nmbd/asyncdns.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index a451f6b617..3d1b3cc995 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -1,8 +1,7 @@ /* Unix SMB/Netbios implementation. - Version 1.9. a async DNS handler - Copyright (C) Andrew Tridgell 1994-1997 + Copyright (C) Andrew Tridgell 1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,13 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - Revision History: - - 14 jan 96: lkcl@pires.co.uk - added multiple workgroup domain master support - -*/ + */ #include "includes.h" -- cgit From c4aaa6bc3f7e8bd823f7279c78583384e7617d93 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 2 Dec 1997 19:00:18 +0000 Subject: asyncdns.c: Removed warning when compiling with -DSYNC_DNS. nameelect.c: Tidied up settings of work->ServerType when unbecoming things. nmbd.c: Fixed pidFile warning. server.c: Fixed pidFile warning. Jeremy. (This used to be commit 94d53dcac5d06e48be5cea9d54625da795f62d20) --- source3/nmbd/asyncdns.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 3d1b3cc995..c87e090754 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -266,7 +266,6 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, struct name_record **n) { - int name_type = question->name_type; char *qname = question->name; struct in_addr dns_ip; -- cgit From bb97a6adacefe2d01ed94a82c0d02801c7e884b1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Dec 1997 08:10:49 +0000 Subject: allow for zero size reads in asyncdns. These can happen after a signal (This used to be commit 8bac91a6e7a3601b093cb64e9cb3bcc1663fb4d4) --- source3/nmbd/asyncdns.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index c87e090754..f15880080f 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -162,13 +162,16 @@ void run_dns_queue(void) { struct query_record r; struct packet_struct *p, *p2; + int size; if (fd_in == -1) return; - if (read_data(fd_in, (char *)&r, sizeof(r)) != sizeof(r)) { - DEBUG(0,("Incomplete DNS answer from child!\n")); - fd_in = -1; + if ((size=read_data(fd_in, (char *)&r, sizeof(r))) != sizeof(r)) { + if (size) { + DEBUG(0,("Incomplete DNS answer from child!\n")); + fd_in = -1; + } return; } -- cgit From 00fc025b93171750cb44a409f9c179d4beba004b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Dec 1997 10:58:40 +0000 Subject: catch signals in the async dns daemon and allow it to auto-restart if necessary (This used to be commit fa599067f074647a5bad2ffd0fce12ae0a4e43d2) --- source3/nmbd/asyncdns.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index f15880080f..57d0eda9b3 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -128,6 +128,10 @@ void start_async_dns(void) fd_in = fd2[0]; fd_out = fd1[1]; + signal(SIGUSR2, SIG_IGN); + signal(SIGUSR1, SIG_IGN); + signal(SIGHUP, SIG_IGN); + asyncdns_process(); } @@ -167,6 +171,11 @@ void run_dns_queue(void) if (fd_in == -1) return; + if (!process_exists(child_pid)) { + close(fd_in); + start_async_dns(); + } + if ((size=read_data(fd_in, (char *)&r, sizeof(r))) != sizeof(r)) { if (size) { DEBUG(0,("Incomplete DNS answer from child!\n")); -- cgit From 64f0348a3f994334abe64a4d4896109c3c8c9039 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 13 Dec 1997 14:16:07 +0000 Subject: This is it ! The mega-merge of the JRA_NMBD_REWRITE branch back into the main tree. For the cvs logs of all the files starting nmbd_*.c, look in the JRA_NMBD_REWRITE branch. That branch has now been discontinued. Jeremy. (This used to be commit d80b0cb645f81d16734929a0b27a91c6650499bb) --- source3/nmbd/asyncdns.c | 64 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 17 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 57d0eda9b3..1ee9dab065 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -22,28 +22,29 @@ extern int DEBUGLEVEL; - /*************************************************************************** - add a DNS result to the name cache - ****************************************************************************/ + Add a DNS result to the name cache. +****************************************************************************/ + static struct name_record *add_dns_result(struct nmb_name *question, struct in_addr addr) { int name_type = question->name_type; char *qname = question->name; - + + if (!addr.s_addr) { /* add the fail to WINS cache of names. give it 1 hour in the cache */ - DEBUG(3,("Negative DNS answer for %s\n", qname)); - add_netbios_entry(wins_client_subnet,qname,name_type,NB_ACTIVE,60*60, - DNSFAIL,addr,True); + DEBUG(3,("add_dns_result: Negative DNS answer for %s\n", qname)); + add_name_to_subnet(wins_server_subnet,qname,name_type, + NB_ACTIVE, 60*60, DNSFAIL_NAME, 1, &addr); return NULL; } /* add it to our WINS cache of names. give it 2 hours in the cache */ - DEBUG(3,("DNS gave answer for %s of %s\n", qname, inet_ntoa(addr))); + DEBUG(3,("add_dns_result: DNS gave answer for %s of %s\n", qname, inet_ntoa(addr))); - return add_netbios_entry(wins_client_subnet,qname,name_type,NB_ACTIVE, - 2*60*60,DNS,addr, True); + return add_name_to_subnet(wins_server_subnet,qname,name_type, + NB_ACTIVE, 2*60*60, DNS_NAME, 1, &addr); } @@ -101,6 +102,23 @@ static void asyncdns_process(void) _exit(0); } +/**************************************************************************** ** + catch a sigterm + We need a separate term handler here so we don't release any + names that our parent is going to release, or overwrite a + WINS db that our parent is going to write. + **************************************************************************** */ + +static int sig_term() +{ + BlockSignals(True,SIGTERM); + + DEBUG(0,("async dns child. Got SIGTERM: going down...\n")); + + exit(0); + /* Keep compiler happy.. */ + return 0; +} /*************************************************************************** create a child process to handle DNS lookups @@ -131,6 +149,7 @@ void start_async_dns(void) signal(SIGUSR2, SIG_IGN); signal(SIGUSR1, SIG_IGN); signal(SIGHUP, SIG_IGN); + signal( SIGTERM, SIGNAL_CAST sig_term ); asyncdns_process(); } @@ -142,7 +161,7 @@ check if a particular name is already being queried static BOOL query_current(struct query_record *r) { return dns_current && - name_equal(&r->name, + nmb_name_equal(&r->name, &dns_current->packet.nmb.question.question_name); } @@ -166,6 +185,7 @@ void run_dns_queue(void) { struct query_record r; struct packet_struct *p, *p2; + struct name_record *namerec; int size; if (fd_in == -1) @@ -184,13 +204,16 @@ void run_dns_queue(void) return; } - add_dns_result(&r.name, r.result); + namerec = add_dns_result(&r.name, r.result); if (dns_current) { if (query_current(&r)) { - DEBUG(3,("DNS calling reply_name_query\n")); + DEBUG(3,("DNS calling send_wins_name_query_response\n")); in_dns = 1; - reply_name_query(dns_current); + if(namerec == NULL) + send_wins_name_query_response(NAM_ERR, dns_current, NULL); + else + send_wins_name_query_response(0,dns_current,namerec); in_dns = 0; } @@ -205,10 +228,13 @@ void run_dns_queue(void) struct nmb_packet *nmb = &p->packet.nmb; struct nmb_name *question = &nmb->question.question_name; - if (name_equal(question, &r.name)) { - DEBUG(3,("DNS calling reply_name_query\n")); + if (nmb_name_equal(question, &r.name)) { + DEBUG(3,("DNS calling send_wins_name_query_response\n")); in_dns = 1; - reply_name_query(p); + if(namerec == NULL) + send_wins_name_query_response(NAM_ERR, p, NULL); + else + send_wins_name_query_response(0,p,namerec); in_dns = 0; p->locked = False; @@ -286,6 +312,10 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, dns_ip.s_addr = interpret_addr(qname); *n = add_dns_result(question, dns_ip); + if(*n == NULL) + send_wins_name_query_response(NAM_ERR, p, NULL); + else + send_wins_name_query_response(0, p, *n); return False; } #endif -- cgit From 65a21bcbddd768a5aa41fc684150d9c5ceb9d5d9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 26 Dec 1997 09:57:40 +0000 Subject: use _exit to exit a child (This used to be commit 992b1cbc143be910d9b8e65afdc82c43d33650a5) --- source3/nmbd/asyncdns.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 1ee9dab065..e0d262f72c 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -111,11 +111,7 @@ static void asyncdns_process(void) static int sig_term() { - BlockSignals(True,SIGTERM); - - DEBUG(0,("async dns child. Got SIGTERM: going down...\n")); - - exit(0); + _exit(0); /* Keep compiler happy.. */ return 0; } @@ -149,7 +145,7 @@ void start_async_dns(void) signal(SIGUSR2, SIG_IGN); signal(SIGUSR1, SIG_IGN); signal(SIGHUP, SIG_IGN); - signal( SIGTERM, SIGNAL_CAST sig_term ); + signal(SIGTERM, SIGNAL_CAST sig_term ); asyncdns_process(); } -- cgit From 55f400bd84f26027f5ec9b7fa06b22895de7557c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Jan 1998 13:27:43 +0000 Subject: This is *not* a big change (although it looks like one). This is merely updating the Copyright statements from 1997 to 1998. It's a once a year thing :-). NO OTHER CHANGES WERE MADE. Jeremy. (This used to be commit b9c16977231efb274e08856f7f3f4408dad6d96c) --- source3/nmbd/asyncdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index e0d262f72c..ee3fdfcd17 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -1,7 +1,7 @@ /* Unix SMB/Netbios implementation. a async DNS handler - Copyright (C) Andrew Tridgell 1997 + Copyright (C) Andrew Tridgell 1997-1998 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit From 89652787c3894c7a79345a2ea67a4de741a0f760 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Jan 1998 08:25:46 +0000 Subject: Makefile: Fix for OSF1 typo. asyncdns.c: Fixes that went into 1.9.18p2 - allow unclocking of sigterm. chgpasswd.c: char -> unsigned char fixes. includes.h: AIX fix to get prototype for inet_ntoa. local.h: Tune size of shared memory based on MAX_OPEN_FILES. nmbd_mynames.c: Fix for nmbd repeated refresh bug. nmbd_responserecordsdb.c: Fix for nmbd repeated refresh bug. nmbd_winsserver.c: Fix for multi-homed registration optimisation. smb.h: Moved default shared memory size to local.h Jeremy. (This used to be commit fa5466805685d461564054d7d9947948fc56ae93) --- source3/nmbd/asyncdns.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index ee3fdfcd17..3b71369d67 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -187,6 +187,9 @@ void run_dns_queue(void) if (fd_in == -1) return; + /* Allow SIGTERM to kill us. */ + BlockSignals(False, SIGTERM); + if (!process_exists(child_pid)) { close(fd_in); start_async_dns(); @@ -197,9 +200,12 @@ void run_dns_queue(void) DEBUG(0,("Incomplete DNS answer from child!\n")); fd_in = -1; } + BlockSignals(True, SIGTERM); return; } + BlockSignals(True, SIGTERM); + namerec = add_dns_result(&r.name, r.result); if (dns_current) { @@ -305,8 +311,14 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, DEBUG(3,("DNS search for %s - ", namestr(question))); + /* Unblock TERM signal so we can be killed in DNS lookup. */ + BlockSignals(False, SIGTERM); + dns_ip.s_addr = interpret_addr(qname); + /* Re-block TERM signal. */ + BlockSignals(True, SIGTERM); + *n = add_dns_result(question, dns_ip); if(*n == NULL) send_wins_name_query_response(NAM_ERR, p, NULL); -- cgit From b7fb6c6b38784d25c9c85e9b27b08e30111dbd0c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 Mar 1998 20:19:14 +0000 Subject: Change the multibyte character set support so that Kanji support is one case of multibyte character support, rather than being a specific case in single byte character support. This allows us to add Big5 Chinese support (code page 950) and Korean Hangul support (code page 949) at very little cost. Also allows us to easily add future multibyte code pages. Makefile: Added codepages 949, 950 as we now support more multibyte codepages. asyncdns.c: Fixed problem with child being re-spawned when parent killed. charcnv.c charset.c client.c clitar.c kanji.c kanji.h smb.h util.c loadparm.c: Generic multibyte codepage support (adding Big5 Chinese and Korean Hangul). nmbd.c: Fixed problem with child being re-spawned when parent killed. mangle.c: Modified str_checksum so that first 15 characters have more effect on outcome. This helps with short name mangling as most 'long' names are still shorter than 15 chars (bug was foobar_mng and foobar_sum would hash to the same value, with the modified code they hash differently. Jeremy. (This used to be commit 299016338cfb47f0c585875ef9b468121fcee97d) --- source3/nmbd/asyncdns.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 3b71369d67..3fb16a08e9 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -103,7 +103,8 @@ static void asyncdns_process(void) } /**************************************************************************** ** - catch a sigterm + catch a sigterm (in the child process - the parent has a different handler + see nmbd.c for details). We need a separate term handler here so we don't release any names that our parent is going to release, or overwrite a WINS db that our parent is going to write. @@ -116,6 +117,17 @@ static int sig_term() return 0; } +/*************************************************************************** + Called by the parent process when it receives a SIGTERM - also kills the + child so we don't get child async dns processes lying around, causing trouble. + ****************************************************************************/ + +void kill_async_dns_child() +{ + if(child_pid != 0 && child_pid != -1) + kill(child_pid, SIGTERM); +} + /*************************************************************************** create a child process to handle DNS lookups ****************************************************************************/ @@ -326,4 +338,12 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, send_wins_name_query_response(0, p, *n); return False; } + +/*************************************************************************** + With sync dns there is no child to kill on SIGTERM. + ****************************************************************************/ +void kill_async_dns_child() +{ + return; +} #endif -- cgit From cac6a060af598bf94e6414b06e7365ec51ca360e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Apr 1998 19:24:06 +0000 Subject: Changes to allow Samba to be compiled with -Wstrict-prototypes with gcc. (Not a big change although it looks like it :-). Jeremy. (This used to be commit cd2613c57261456485fe4eeecfda209ada70de8e) --- source3/nmbd/asyncdns.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 3fb16a08e9..6019819793 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -110,7 +110,7 @@ static void asyncdns_process(void) WINS db that our parent is going to write. **************************************************************************** */ -static int sig_term() +static int sig_term(void) { _exit(0); /* Keep compiler happy.. */ @@ -122,7 +122,7 @@ static int sig_term() child so we don't get child async dns processes lying around, causing trouble. ****************************************************************************/ -void kill_async_dns_child() +void kill_async_dns_child(void) { if(child_pid != 0 && child_pid != -1) kill(child_pid, SIGTERM); @@ -342,7 +342,7 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, /*************************************************************************** With sync dns there is no child to kill on SIGTERM. ****************************************************************************/ -void kill_async_dns_child() +void kill_async_dns_child(void) { return; } -- cgit From f3e26636452de78e1acb68de3823fe031aee4b3e Mon Sep 17 00:00:00 2001 From: "Christopher R. Hertel" Date: Mon, 8 Jun 1998 03:44:13 +0000 Subject: Cosmetic. Added a cast to (void) to a call to add_name_to_subnet() since the return value was being ignored anyway. SGI's lint said: function returns value which is sometimes ignored add_name_to_subnet Chris -)----- (This used to be commit ae706bff10cc77f06b8069e637ec9768d6a46966) --- source3/nmbd/asyncdns.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 6019819793..3d2d5303de 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -35,16 +35,16 @@ static struct name_record *add_dns_result(struct nmb_name *question, struct in_a if (!addr.s_addr) { /* add the fail to WINS cache of names. give it 1 hour in the cache */ DEBUG(3,("add_dns_result: Negative DNS answer for %s\n", qname)); - add_name_to_subnet(wins_server_subnet,qname,name_type, - NB_ACTIVE, 60*60, DNSFAIL_NAME, 1, &addr); - return NULL; + (void)add_name_to_subnet( wins_server_subnet, qname, name_type, + NB_ACTIVE, 60*60, DNSFAIL_NAME, 1, &addr ); + return( NULL ); } /* add it to our WINS cache of names. give it 2 hours in the cache */ DEBUG(3,("add_dns_result: DNS gave answer for %s of %s\n", qname, inet_ntoa(addr))); - return add_name_to_subnet(wins_server_subnet,qname,name_type, - NB_ACTIVE, 2*60*60, DNS_NAME, 1, &addr); + return( add_name_to_subnet( wins_server_subnet, qname, name_type, + NB_ACTIVE, 2*60*60, DNS_NAME, 1, &addr ) ); } -- cgit From 64578c0589a3a741f81fb55c16eeb882128da00b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jul 1998 03:08:05 +0000 Subject: merge from the autoconf2 branch to the main branch (This used to be commit 3bda7ac417107a7b01d91805ca71c4330657ed21) --- source3/nmbd/asyncdns.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 3d2d5303de..89be2b0ce0 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -135,7 +135,7 @@ void start_async_dns(void) { int fd1[2], fd2[2]; - signal(SIGCLD, SIG_IGN); + CatchChild(); if (pipe(fd1) || pipe(fd2)) { return; @@ -154,10 +154,10 @@ void start_async_dns(void) fd_in = fd2[0]; fd_out = fd1[1]; - signal(SIGUSR2, SIG_IGN); - signal(SIGUSR1, SIG_IGN); - signal(SIGHUP, SIG_IGN); - signal(SIGTERM, SIGNAL_CAST sig_term ); + CatchSignal(SIGUSR2, SIG_IGN); + CatchSignal(SIGUSR1, SIG_IGN); + CatchSignal(SIGHUP, SIG_IGN); + CatchSignal(SIGTERM, SIGNAL_CAST sig_term ); asyncdns_process(); } -- cgit From e13aeea928dd89373cfaf3916c96f853c1227884 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 15 Aug 1998 01:19:26 +0000 Subject: configure: Changes for extra headers. configure.in: Source for header changes. client/clitar.c: Fixed isXXX macros & debugs for gcc pedantic compile. include/config.h.in: Added MEMSET, BZERO, MEMORY, RPCSVC_YPCLNT, STRINGS headers. include/includes.h: Headers for the above. include/smb.h: Made SIGNAL_CAST POSIX by default void (*)(int). lib/access.c: Fixed isXXX macros & debugs for gcc pedantic compile. lib/charset.c: Fixed isXXX macros & debugs for gcc pedantic compile. lib/debug.c: Fixed signal functs. lib/kanji.c: Fixed isXXX macros & debugs for gcc pedantic compile. lib/smbrun.c: Fixed isXXX macros & debugs for gcc pedantic compile. lib/util.c: Fixed isXXX macros & debugs for gcc pedantic compile. libsmb/namequery.c: Fixed isXXX macros & debugs for gcc pedantic compile. locking/shmem.c: Fixed isXXX macros & debugs for gcc pedantic compile. locking/shmem_sysv.c: Fixed error messages in sysV stuff. nmbd/asyncdns.c: Fixed signal functs. nmbd/nmbd.c: Fixed isXXX macros & debugs for gcc pedantic compile. passdb/passdb.c: Fixed isXXX macros & debugs for gcc pedantic compile. passdb/smbpassfile.c: Fixed isXXX macros & debugs for gcc pedantic compile. smbd/chgpasswd.c: Fixed isXXX macros & debugs for gcc pedantic compile. smbd/ipc.c: Fixed isXXX macros & debugs for gcc pedantic compile. smbd/nttrans.c: Fixed fsp code path. smbd/password.c: fixed HAVE_YP_GET_DEFAULT_DOMAIN problem. smbd/printing.c: Fixed isXXX macros & debugs for gcc pedantic compile. smbd/reply.c: Fixed isXXX macros & debugs for gcc pedantic compile. smbd/server.c: Fixed isXXX macros & debugs for gcc pedantic compile. smbd/trans2.c: Fixed core dump bug. smbd/uid.c: Fixed isXXX macros & debugs for gcc pedantic compile. Jeremy. (This used to be commit 1b9cbcd02e575dc0a95fa589f720df30a4acc46b) --- source3/nmbd/asyncdns.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 89be2b0ce0..9926045d82 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -110,11 +110,9 @@ static void asyncdns_process(void) WINS db that our parent is going to write. **************************************************************************** */ -static int sig_term(void) +static void sig_term(int sig) { _exit(0); - /* Keep compiler happy.. */ - return 0; } /*************************************************************************** -- cgit From 98b0fafc6132e12bc9b7e39784cb2e221a8a5125 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 30 Aug 1998 16:33:48 +0000 Subject: a couple of debug lines (This used to be commit 03d343ddf5ef672afb3cf1fa65f86eb2c0a48772) --- source3/nmbd/asyncdns.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 9926045d82..8f28f515ea 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -136,6 +136,7 @@ void start_async_dns(void) CatchChild(); if (pipe(fd1) || pipe(fd2)) { + DEBUG(0,("can't create asyncdns pipes\n")); return; } @@ -146,6 +147,7 @@ void start_async_dns(void) fd_out = fd2[1]; close(fd1[1]); close(fd2[0]); + DEBUG(0,("started asyncdns process %d\n", child_pid)); return; } -- cgit From ac9b687cc2496409e1c8d86393812faf94ec7550 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 17 Sep 1998 19:16:12 +0000 Subject: configure configure.in: Added tests for fseek64 and ftell64. config.h.in: Added fseek64 and ftell64. includes.h: Added definition of SMB_BIG_INTEGER. smb.h: Changed (*getsmbpwpos) and (*setsmbpwpos) to use SMB_BIG_INTEGER. access.c: Tidyup of dbug statement. system.c: Added sys_fseek and sys_ftell. Changed mode calls to use mode_t. asyncdns.c: Tidyup of comment. loadparm.c: Tidyup of set_default_server_announce_type() function definition. ldap.c: Changed (*getsmbpwpos) and (*setsmbpwpos) to use SMB_BIG_INTEGER. nispass.c: Changed (*getsmbpwpos) and (*setsmbpwpos) to use SMB_BIG_INTEGER. smbpass.c: Changed (*getsmbpwpos) and (*setsmbpwpos) to use SMB_BIG_INTEGER. smbpassfile.c: Use sys_fseek(). chgpasswd.c: Tidyup of debug statement. dosmode.c: Changed mode calls to use mode_t. ipc.c: Removal of dead code. nttrans.c: Changed mode calls to use mode_t. open.c: Changed mode calls to use mode_t. pipes.c: Removal of dead code. reply.c: Removal of dead code. trans2.c: Removal of dead code. Changed mode calls to use mode_t. Jeremy. (This used to be commit c381d32e3dc23fe887408016cae821aceb30da2c) --- source3/nmbd/asyncdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 8f28f515ea..3054ad7353 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -313,7 +313,7 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, /*************************************************************************** - we use this then we can't do async DNS lookups + we use this when we can't do async DNS lookups ****************************************************************************/ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, struct name_record **n) -- cgit From 24ca89bfb03fb82e975eff94070275ee403cd0f9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 14 Nov 1998 01:04:13 +0000 Subject: Removed acconfig.h configure configure.in include/config.h.in: Made smbwrapper not made by default. nmbd*: Changed all calls to namestr() to nmbd_namestr() to fix broken FreeBSD include file problem...sigh. Jeremy. (This used to be commit 9ee8f39aed8772a05c203161b4ae6b7d90d67481) --- source3/nmbd/asyncdns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 3054ad7353..67e55ebd50 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -305,7 +305,7 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, dns_queue = p; } - DEBUG(3,("added DNS query for %s\n", namestr(question))); + DEBUG(3,("added DNS query for %s\n", nmb_namestr(question))); return True; } @@ -321,7 +321,7 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, char *qname = question->name; struct in_addr dns_ip; - DEBUG(3,("DNS search for %s - ", namestr(question))); + DEBUG(3,("DNS search for %s - ", nmb_namestr(question))); /* Unblock TERM signal so we can be killed in DNS lookup. */ BlockSignals(False, SIGTERM); -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/nmbd/asyncdns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 67e55ebd50..99e697b470 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -52,7 +52,7 @@ static struct name_record *add_dns_result(struct nmb_name *question, struct in_a #ifndef SYNC_DNS static int fd_in = -1, fd_out = -1; -static int child_pid = -1; +static pid_t child_pid = -1; static int in_dns; /* this is the structure that is passed between the parent and child */ @@ -147,7 +147,7 @@ void start_async_dns(void) fd_out = fd2[1]; close(fd1[1]); close(fd2[0]); - DEBUG(0,("started asyncdns process %d\n", child_pid)); + DEBUG(0,("started asyncdns process %d\n", (int)child_pid)); return; } -- cgit From 693ffb8466ada58ecc59fde754ba79fc6f51528d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 2 May 2000 02:23:41 +0000 Subject: Added sys_fork() and sys_getpid() functions to stop the overhead of doing a system call every time we want to just get our pid. Jeremy. (This used to be commit 148628b616b5c29ba6340d65fc3ddbcabba6e67a) --- source3/nmbd/asyncdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 99e697b470..1fe04a39e3 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -140,7 +140,7 @@ void start_async_dns(void) return; } - child_pid = fork(); + child_pid = sys_fork(); if (child_pid) { fd_in = fd1[0]; -- cgit From dc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Oct 2001 04:29:50 +0000 Subject: Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header. (This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e) --- source3/nmbd/asyncdns.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 1fe04a39e3..5ae2eb202d 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -20,8 +20,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /*************************************************************************** Add a DNS result to the name cache. ****************************************************************************/ -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/nmbd/asyncdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 5ae2eb202d..c5ff718836 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -1,5 +1,5 @@ /* - Unix SMB/Netbios implementation. + Unix SMB/CIFS implementation. a async DNS handler Copyright (C) Andrew Tridgell 1997-1998 -- cgit From 75722fa183d1678bc7360bc79f9ac8cf17cd62e3 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 20 Mar 2002 06:57:03 +0000 Subject: Add assertions that kill() is never accidentally passed a non-positive pid. This follows a bug in rsync where it would accidentally kill(-1), removing all the user's processes. I can't see any way this would directly happen in Samba, but having the assertions seems beneficial. http://cvs.samba.org/cgi-bin/cvsweb/rsync/util.c.diff?r1=1.108&r2=1.109&f=h (This used to be commit 098905bea29c7d5b886809d431294ddf2fc1e152) --- source3/nmbd/asyncdns.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index c5ff718836..6c2f8de3b1 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -120,8 +120,9 @@ static void sig_term(int sig) void kill_async_dns_child(void) { - if(child_pid != 0 && child_pid != -1) - kill(child_pid, SIGTERM); + if (child_pid > 0) { + kill(child_pid, SIGTERM); + } } /*************************************************************************** -- cgit From b2edf254eda92f775e7d3d9b6793b4d77f9000b6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 17 Aug 2002 17:00:51 +0000 Subject: sync 3.0 branch with head (This used to be commit 3928578b52cfc949be5e0ef444fce1558d75f290) --- source3/nmbd/asyncdns.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 6c2f8de3b1..c86ee69a09 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -122,6 +122,7 @@ void kill_async_dns_child(void) { if (child_pid > 0) { kill(child_pid, SIGTERM); + child_pid = -1; } } -- cgit From 9fdc1363bec6ae9a0a0f9a37130b98a92ebe8ce2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Aug 2003 01:25:01 +0000 Subject: Fix the character set handling properly in nmbd. Also fix bug where iconv wasn't re-initialised on reading of "charset" parameters. This caused workgroup name to be set incorrectly if it contained an extended character. Jeremy. (This used to be commit 84ae44678a6c59c999bc1023fdd9b7ad87f4ec18) --- source3/nmbd/asyncdns.c | 73 ++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 34 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index c86ee69a09..6d5d487b11 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -26,26 +26,25 @@ static struct name_record *add_dns_result(struct nmb_name *question, struct in_addr addr) { - int name_type = question->name_type; - char *qname = question->name; - + int name_type = question->name_type; + nstring qname; + + pull_ascii_nstring(qname, question->name); - if (!addr.s_addr) { - /* add the fail to WINS cache of names. give it 1 hour in the cache */ - DEBUG(3,("add_dns_result: Negative DNS answer for %s\n", qname)); - (void)add_name_to_subnet( wins_server_subnet, qname, name_type, - NB_ACTIVE, 60*60, DNSFAIL_NAME, 1, &addr ); - return( NULL ); - } - - /* add it to our WINS cache of names. give it 2 hours in the cache */ - DEBUG(3,("add_dns_result: DNS gave answer for %s of %s\n", qname, inet_ntoa(addr))); - - return( add_name_to_subnet( wins_server_subnet, qname, name_type, - NB_ACTIVE, 2*60*60, DNS_NAME, 1, &addr ) ); -} + if (!addr.s_addr) { + /* add the fail to WINS cache of names. give it 1 hour in the cache */ + DEBUG(3,("add_dns_result: Negative DNS answer for %s\n", qname)); + (void)add_name_to_subnet( wins_server_subnet, qname, name_type, + NB_ACTIVE, 60*60, DNSFAIL_NAME, 1, &addr ); + return( NULL ); + } + /* add it to our WINS cache of names. give it 2 hours in the cache */ + DEBUG(3,("add_dns_result: DNS gave answer for %s of %s\n", qname, inet_ntoa(addr))); + return( add_name_to_subnet( wins_server_subnet, qname, name_type, + NB_ACTIVE, 2*60*60, DNS_NAME, 1, &addr ) ); +} #ifndef SYNC_DNS @@ -70,6 +69,7 @@ static struct packet_struct *dns_current; return the fd used to gather async dns replies. This is added to the select loop ****************************************************************************/ + int asyncdns_fd(void) { return fd_in; @@ -110,7 +110,7 @@ static void asyncdns_process(void) static void sig_term(int sig) { - _exit(0); + _exit(0); } /*************************************************************************** @@ -224,10 +224,10 @@ void run_dns_queue(void) if (query_current(&r)) { DEBUG(3,("DNS calling send_wins_name_query_response\n")); in_dns = 1; - if(namerec == NULL) - send_wins_name_query_response(NAM_ERR, dns_current, NULL); - else - send_wins_name_query_response(0,dns_current,namerec); + if(namerec == NULL) + send_wins_name_query_response(NAM_ERR, dns_current, NULL); + else + send_wins_name_query_response(0,dns_current,namerec); in_dns = 0; } @@ -245,10 +245,10 @@ void run_dns_queue(void) if (nmb_name_equal(question, &r.name)) { DEBUG(3,("DNS calling send_wins_name_query_response\n")); in_dns = 1; - if(namerec == NULL) - send_wins_name_query_response(NAM_ERR, p, NULL); - else - send_wins_name_query_response(0,p,namerec); + if(namerec == NULL) + send_wins_name_query_response(NAM_ERR, p, NULL); + else + send_wins_name_query_response(0,p,namerec); in_dns = 0; p->locked = False; @@ -269,7 +269,8 @@ void run_dns_queue(void) if (dns_queue) { dns_current = dns_queue; dns_queue = dns_queue->next; - if (dns_queue) dns_queue->prev = NULL; + if (dns_queue) + dns_queue->prev = NULL; dns_current->next = NULL; if (!write_child(dns_current)) { @@ -277,12 +278,12 @@ void run_dns_queue(void) return; } } - } /*************************************************************************** queue a DNS query ****************************************************************************/ + BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, struct name_record **n) { @@ -315,11 +316,14 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, /*************************************************************************** we use this when we can't do async DNS lookups ****************************************************************************/ + BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, struct name_record **n) { - char *qname = question->name; struct in_addr dns_ip; + nstring qname; + + pull_ascii_nstring(qname, question->name); DEBUG(3,("DNS search for %s - ", nmb_namestr(question))); @@ -332,18 +336,19 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, BlockSignals(True, SIGTERM); *n = add_dns_result(question, dns_ip); - if(*n == NULL) - send_wins_name_query_response(NAM_ERR, p, NULL); - else - send_wins_name_query_response(0, p, *n); + if(*n == NULL) + send_wins_name_query_response(NAM_ERR, p, NULL); + else + send_wins_name_query_response(0, p, *n); return False; } /*************************************************************************** With sync dns there is no child to kill on SIGTERM. ****************************************************************************/ + void kill_async_dns_child(void) { - return; + return; } #endif -- cgit From 6b9dbbcd249360fb9acd61d6900baccf621c9cce Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 13 Mar 2004 02:16:21 +0000 Subject: Modified fix for bugid #784. Based on a patch from moriyama@miraclelinux.com (MORIYAMA Masayuki). Don't use nstrings to hold workgroup and netbios names. The problem with them is that MB netbios and workgroup names in unix charset (particularly utf8) may be up to 3x bigger than the name when represented in dos charset (ie. cp932). So go back to using fstrings for these but translate into nstrings (ie. 16 byte length values) for transport on the wire. Jeremy. (This used to be commit b4ea493599ab414f7828b83f40a5a8b43479ff64) --- source3/nmbd/asyncdns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 6d5d487b11..dafbff7af2 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -27,9 +27,9 @@ static struct name_record *add_dns_result(struct nmb_name *question, struct in_addr addr) { int name_type = question->name_type; - nstring qname; + fstring qname; - pull_ascii_nstring(qname, question->name); + pull_ascii_nstring(qname, sizeof(qname), question->name); if (!addr.s_addr) { /* add the fail to WINS cache of names. give it 1 hour in the cache */ -- cgit From ce0c99312c7da78679357610730ba5b60f4319b9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 15 Mar 2004 21:45:45 +0000 Subject: Use "unix netbios name" type unstring - 64 bytes long to manipulate netbios names in nmbd. Allows conversion from dos codepage mb strings (ie. SJIS) to expand to utf8 size on read. Jeremy. (This used to be commit 834d816caf9cd6318da00febde50d9233469dac2) --- source3/nmbd/asyncdns.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index dafbff7af2..653cb97fbb 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -27,7 +27,7 @@ static struct name_record *add_dns_result(struct nmb_name *question, struct in_addr addr) { int name_type = question->name_type; - fstring qname; + unstring qname; pull_ascii_nstring(qname, sizeof(qname), question->name); @@ -81,7 +81,7 @@ int asyncdns_fd(void) static void asyncdns_process(void) { struct query_record r; - fstring qname; + unstring qname; DEBUGLEVEL = -1; @@ -89,8 +89,7 @@ static void asyncdns_process(void) if (read_data(fd_in, (char *)&r, sizeof(r)) != sizeof(r)) break; - fstrcpy(qname, r.name.name); - + pull_ascii_nstring( qname, sizeof(qname), r.name.name); r.result.s_addr = interpret_addr(qname); if (write_data(fd_out, (char *)&r, sizeof(r)) != sizeof(r)) @@ -321,7 +320,7 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, struct name_record **n) { struct in_addr dns_ip; - nstring qname; + unstring qname; pull_ascii_nstring(qname, question->name); -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/nmbd/asyncdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 653cb97fbb..4db54ea198 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -201,7 +201,7 @@ void run_dns_queue(void) /* Allow SIGTERM to kill us. */ BlockSignals(False, SIGTERM); - if (!process_exists(child_pid)) { + if (!process_exists_by_pid(child_pid)) { close(fd_in); start_async_dns(); } -- cgit From 83b987befdbba857131102700d237728784b6f69 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 6 Dec 2005 23:06:38 +0000 Subject: r12107: Move to a tdb-based wins database. At the moment we still use it as though it were an in-memory db and dump out to a flat file every 2 mins, but that can now change. Jeremy. (This used to be commit a342681792724c1ae8561ba8d352c4ee6e2a5332) --- source3/nmbd/asyncdns.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 4db54ea198..c0626d1161 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -34,16 +34,18 @@ static struct name_record *add_dns_result(struct nmb_name *question, struct in_a if (!addr.s_addr) { /* add the fail to WINS cache of names. give it 1 hour in the cache */ DEBUG(3,("add_dns_result: Negative DNS answer for %s\n", qname)); - (void)add_name_to_subnet( wins_server_subnet, qname, name_type, + add_name_to_subnet( wins_server_subnet, qname, name_type, NB_ACTIVE, 60*60, DNSFAIL_NAME, 1, &addr ); - return( NULL ); + return NULL; } /* add it to our WINS cache of names. give it 2 hours in the cache */ DEBUG(3,("add_dns_result: DNS gave answer for %s of %s\n", qname, inet_ntoa(addr))); - return( add_name_to_subnet( wins_server_subnet, qname, name_type, - NB_ACTIVE, 2*60*60, DNS_NAME, 1, &addr ) ); + add_name_to_subnet( wins_server_subnet, qname, name_type, + NB_ACTIVE, 2*60*60, DNS_NAME, 1, &addr); + + return find_name_on_subnet(wins_server_subnet, question, FIND_ANY_NAME); } #ifndef SYNC_DNS @@ -283,8 +285,7 @@ void run_dns_queue(void) queue a DNS query ****************************************************************************/ -BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, - struct name_record **n) +BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question) { if (in_dns || fd_in == -1) return False; @@ -316,9 +317,9 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, we use this when we can't do async DNS lookups ****************************************************************************/ -BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, - struct name_record **n) +BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question) { + struct name_record *namerec = NULL; struct in_addr dns_ip; unstring qname; @@ -334,11 +335,12 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, /* Re-block TERM signal. */ BlockSignals(True, SIGTERM); - *n = add_dns_result(question, dns_ip); - if(*n == NULL) + namerec = add_dns_result(question, dns_ip); + if(namerec == NULL) { send_wins_name_query_response(NAM_ERR, p, NULL); - else - send_wins_name_query_response(0, p, *n); + } else { + send_wins_name_query_response(0, p, namerec); + } return False; } -- cgit From 4d3152e1454ce62f3d1f864ccbf2a58234dab09d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Dec 2005 19:37:05 +0000 Subject: r12214: Fix compile if SYNC_DNS is set. Jeremy. (This used to be commit 7c545e1e77c3e235b21eb11d5ced91c603da491d) --- source3/nmbd/asyncdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index c0626d1161..c8caa3fee2 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -323,7 +323,7 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question) struct in_addr dns_ip; unstring qname; - pull_ascii_nstring(qname, question->name); + pull_ascii_nstring(qname, sizeof(qname), question->name); DEBUG(3,("DNS search for %s - ", nmb_namestr(question))); -- cgit From 22c7238825112813444012289c898086b2414bd4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 24 Aug 2006 20:42:31 +0000 Subject: r17807: Fix a file descriptor leak pointed out by John Malmberg. Thanks! Volker (This used to be commit fac007ccbec75f5ee9ff2769d8add4d27e62167d) --- source3/nmbd/asyncdns.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index c8caa3fee2..0c7a1e50b7 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -205,6 +205,7 @@ void run_dns_queue(void) if (!process_exists_by_pid(child_pid)) { close(fd_in); + close(fd_out); start_async_dns(); } -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/nmbd/asyncdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 0c7a1e50b7..25bbcabe5c 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/nmbd/asyncdns.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 25bbcabe5c..f572aefc78 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/nmbd/asyncdns.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index f572aefc78..b9c9ffb1c6 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -166,7 +166,7 @@ void start_async_dns(void) /*************************************************************************** check if a particular name is already being queried ****************************************************************************/ -static BOOL query_current(struct query_record *r) +static bool query_current(struct query_record *r) { return dns_current && nmb_name_equal(&r->name, @@ -177,7 +177,7 @@ static BOOL query_current(struct query_record *r) /*************************************************************************** write a query to the child process ****************************************************************************/ -static BOOL write_child(struct packet_struct *p) +static bool write_child(struct packet_struct *p) { struct query_record r; @@ -285,7 +285,7 @@ void run_dns_queue(void) queue a DNS query ****************************************************************************/ -BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question) +bool queue_dns_query(struct packet_struct *p,struct nmb_name *question) { if (in_dns || fd_in == -1) return False; @@ -317,7 +317,7 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question) we use this when we can't do async DNS lookups ****************************************************************************/ -BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question) +bool queue_dns_query(struct packet_struct *p,struct nmb_name *question) { struct name_record *namerec = NULL; struct in_addr dns_ip; -- cgit From 36441da4240f3e3a296eed65f0796b25b7b05a3a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 5 Nov 2007 11:12:56 -0800 Subject: Remove the horror that was the global smb_rw_error. Each cli struct has it's own local copy of this variable, so use that in client code. In the smbd server, add one static to smbd/proccess.c and use that inside smbd. Fix a bunch of places where smb_rw_error could be set by calling read_data() in places where we weren't reading from the SMB client socket (ie. winbindd). Jeremy. (This used to be commit 255c2adf7b6ef30932b5bb9f142ccef4a5d3d0db) --- source3/nmbd/asyncdns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index b9c9ffb1c6..33c1cb6cb1 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -87,7 +87,7 @@ static void asyncdns_process(void) DEBUGLEVEL = -1; while (1) { - if (read_data(fd_in, (char *)&r, sizeof(r)) != sizeof(r)) + if (read_data(fd_in, (char *)&r, sizeof(r), NULL) != sizeof(r)) break; pull_ascii_nstring( qname, sizeof(qname), r.name.name); @@ -208,7 +208,7 @@ void run_dns_queue(void) start_async_dns(); } - if ((size=read_data(fd_in, (char *)&r, sizeof(r))) != sizeof(r)) { + if ((size=read_data(fd_in, (char *)&r, sizeof(r), NULL)) != sizeof(r)) { if (size) { DEBUG(0,("Incomplete DNS answer from child!\n")); fd_in = -1; -- cgit From b42a5d68a3ffd88fd60c64b6a75fe2d687d9c92d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Jan 2008 10:39:21 +0100 Subject: Convert read_data() to NTSTATUS (This used to be commit af40b71023f8c4a2133d996ea698c72b97624043) --- source3/nmbd/asyncdns.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 33c1cb6cb1..5e5565991e 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -87,8 +87,13 @@ static void asyncdns_process(void) DEBUGLEVEL = -1; while (1) { - if (read_data(fd_in, (char *)&r, sizeof(r), NULL) != sizeof(r)) + NTSTATUS status; + + status = read_data(fd_in, (char *)&r, sizeof(r)); + + if (!NT_STATUS_IS_OK(status)) { break; + } pull_ascii_nstring( qname, sizeof(qname), r.name.name); r.result.s_addr = interpret_addr(qname); @@ -194,7 +199,7 @@ void run_dns_queue(void) struct query_record r; struct packet_struct *p, *p2; struct name_record *namerec; - int size; + NTSTATUS status; if (fd_in == -1) return; @@ -208,11 +213,11 @@ void run_dns_queue(void) start_async_dns(); } - if ((size=read_data(fd_in, (char *)&r, sizeof(r), NULL)) != sizeof(r)) { - if (size) { - DEBUG(0,("Incomplete DNS answer from child!\n")); - fd_in = -1; - } + status = read_data(fd_in, (char *)&r, sizeof(r)); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("read from child failed: %s\n", nt_errstr(status))); + fd_in = -1; BlockSignals(True, SIGTERM); return; } -- cgit From c5d1a3c710472711baeb8d1b74951f3006f48aaa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 15 Apr 2008 10:38:21 +0200 Subject: nmbd: call reinit_after_fork() in all needed cases metze (This used to be commit f68829ff14c457bfa98cb2ef9e8ec2e1a0b1d64d) --- source3/nmbd/asyncdns.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 5e5565991e..0329491c4a 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -164,6 +164,11 @@ void start_async_dns(void) CatchSignal(SIGHUP, SIG_IGN); CatchSignal(SIGTERM, SIGNAL_CAST sig_term ); + if (!reinit_after_fork(nmbd_messaging_context())) { + DEBUG(0,("reinit_after_fork() failed\n")); + smb_panic("reinit_after_fork() failed"); + } + asyncdns_process(); } -- cgit From 0c4093a234dfaca6d363a6e1358f2fbf421dcd3c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 23 Apr 2008 17:13:50 +0200 Subject: Fix CLEAR_IF_FIRST handling of messages.tdb We now open messages.tdb even before we do the become_daemon. become_daemon() involves a fork and an immediate exit of the parent, thus the parent_is_longlived argument must be set to false in this case. The parent is not really long lived :-) (This used to be commit 4f4781c6d17fe2db34dd5945fec52a7685448aec) --- source3/nmbd/asyncdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/nmbd/asyncdns.c') diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index 0329491c4a..ab9b1ed740 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -164,7 +164,7 @@ void start_async_dns(void) CatchSignal(SIGHUP, SIG_IGN); CatchSignal(SIGTERM, SIGNAL_CAST sig_term ); - if (!reinit_after_fork(nmbd_messaging_context())) { + if (!reinit_after_fork(nmbd_messaging_context(), true)) { DEBUG(0,("reinit_after_fork() failed\n")); smb_panic("reinit_after_fork() failed"); } -- cgit