From 77be0f710cc96441d966ab7b026a0d591b01ffb0 Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Fri, 6 Jun 1997 16:14:17 +0000 Subject: loadparm.c: Made explicit max packet now ignored. namedbwork.c: Don't announce potential browser if local master = False. nameelect.c: Raise debug level of comment to 2. proto.h: Added reset_globals_after_fork(). server.c: Call reset_globals_after_fork() after forking child. util.c: Added reset_globals_after_fork() - should stop problems with % substitutions in children. --- source/include/proto.h | 1 + source/lib/util.c | 37 ++++++++++++++++++++++++++++--------- source/namedbwork.c | 3 ++- source/nameelect.c | 2 +- source/param/loadparm.c | 2 +- source/smbd/server.c | 8 +++++++- 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/source/include/proto.h b/source/include/proto.h index 2b30b7174ea..66e626487ef 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -929,6 +929,7 @@ int interpret_security(char *str,int def); uint32 interpret_addr(char *str); struct in_addr *interpret_addr2(char *str); BOOL zero_ip(struct in_addr ip); +void reset_globals_after_fork(); char *client_name(void); char *client_addr(void); void standard_sub_basic(char *s); diff --git a/source/lib/util.c b/source/lib/util.c index 831d7d64e07..610f9f46a59 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -3036,7 +3036,9 @@ BOOL zero_ip(struct in_addr ip) } -/* matchname - determine if host name matches IP address */ +/******************************************************************* + matchname - determine if host name matches IP address + ******************************************************************/ static BOOL matchname(char *remotehost,struct in_addr addr) { struct hostent *hp; @@ -3079,7 +3081,24 @@ static BOOL matchname(char *remotehost,struct in_addr addr) return False; } -/* return the DNS name of the client */ +/******************************************************************* + Reset the 'done' variables so after a client process is created + from a fork call these calls will be re-done. This should be + expanded if more variables need reseting. + ******************************************************************/ + +static BOOL global_client_name_done = False; +static BOOL global_client_addr_done = False; + +void reset_globals_after_fork() +{ + global_client_name_done = False; + global_client_addr_done = False; +} + +/******************************************************************* + return the DNS name of the client + ******************************************************************/ char *client_name(void) { extern int Client; @@ -3087,10 +3106,9 @@ char *client_name(void) struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa); int length = sizeof(sa); static pstring name_buf; - static BOOL done = False; struct hostent *hp; - if (done) + if (global_client_name_done) return name_buf; strcpy(name_buf,"UNKNOWN"); @@ -3113,11 +3131,13 @@ char *client_name(void) strcpy(name_buf,"UNKNOWN"); } } - done = True; + global_client_name_done = True; return name_buf; } -/* return the IP addr of the client as a string */ +/******************************************************************* + return the IP addr of the client as a string + ******************************************************************/ char *client_addr(void) { extern int Client; @@ -3125,9 +3145,8 @@ char *client_addr(void) struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa); int length = sizeof(sa); static fstring addr_buf; - static BOOL done = False; - if (done) + if (global_client_addr_done) return addr_buf; strcpy(addr_buf,"0.0.0.0"); @@ -3139,7 +3158,7 @@ char *client_addr(void) strcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr)); - done = True; + global_client_addr_done = True; return addr_buf; } diff --git a/source/namedbwork.c b/source/namedbwork.c index d752916815f..a17de731bb1 100644 --- a/source/namedbwork.c +++ b/source/namedbwork.c @@ -88,7 +88,8 @@ static struct work_record *make_workgroup(char *name) StrnCpy(work->work_group,name,sizeof(work->work_group)-1); work->serverlist = NULL; - work->ServerType = DFLT_SERVER_TYPE | SV_TYPE_POTENTIAL_BROWSER; + work->ServerType = DFLT_SERVER_TYPE | (lp_local_master() ? + SV_TYPE_POTENTIAL_BROWSER : 0 ); work->RunningElection = False; work->ElectionCount = 0; work->needelection = False; diff --git a/source/nameelect.c b/source/nameelect.c index 258ee98931e..a53f86dcee6 100644 --- a/source/nameelect.c +++ b/source/nameelect.c @@ -82,7 +82,7 @@ void check_master_browser(time_t t) becoming a master browser, hence the log message. */ - DEBUG(0,("%s potential master for %s %s - force election\n", + DEBUG(2,("%s potential master for %s %s - force election\n", timestring(), work->work_group, inet_ntoa(d->bcast_ip))); diff --git a/source/param/loadparm.c b/source/param/loadparm.c index ddd8cc90ba0..b368d3b2fa9 100644 --- a/source/param/loadparm.c +++ b/source/param/loadparm.c @@ -587,7 +587,7 @@ static void init_globals(void) Globals.bUseRhosts = False; Globals.max_packet = 65535; Globals.mangled_stack = 50; - Globals.max_xmit = Globals.max_packet; + Globals.max_xmit = 65535; Globals.max_mux = 2; Globals.lpqcachetime = 10; Globals.pwordlevel = 0; diff --git a/source/smbd/server.c b/source/smbd/server.c index 51710b7b779..299ae07aa30 100644 --- a/source/smbd/server.c +++ b/source/smbd/server.c @@ -2065,6 +2065,7 @@ static BOOL open_sockets(BOOL is_daemon,int port) #else if (Client != -1 && fork()==0) { + /* Child code ... */ #ifndef NO_SIGNAL_TEST signal(SIGPIPE, SIGNAL_CAST sig_pipe); signal(SIGCLD, SIGNAL_CAST SIG_DFL); @@ -2079,6 +2080,11 @@ static BOOL open_sockets(BOOL is_daemon,int port) set_socket_options(Client,"SO_KEEPALIVE"); set_socket_options(Client,user_socket_options); + /* Reset global variables in util.c so that + client substitutions will be done correctly + in the process. + */ + reset_globals_after_fork(); return True; } close(Client); /* The parent doesn't need this socket */ @@ -3119,7 +3125,7 @@ BOOL yield_connection(int cnum,char *name,int max_connections) f = fopen(fname,"r+"); if (!f) { - DEBUG(2,("Coudn't open lock file %s (%s)\n",fname,strerror(errno))); + DEBUG(2,("Couldn't open lock file %s (%s)\n",fname,strerror(errno))); return(False); } -- cgit