From f9e940efc715a03d70791fd747993d56383706ff Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 May 1998 10:52:54 +0000 Subject: [PATCH] load just the globals section of the config file when the daemon starts so we know the syslog facility for the "starting" message --- clientserver.c | 11 +++++++++-- loadparm.c | 25 +++++++++++++------------ params.c | 10 ++++++---- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/clientserver.c b/clientserver.c index 9cac2ef3..121252b4 100644 --- a/clientserver.c +++ b/clientserver.c @@ -266,7 +266,7 @@ static int start_daemon(int fd) extern char *config_file; extern int remote_version; - if (!lp_load(config_file)) { + if (!lp_load(config_file, 0)) { exit_cleanup(1); } @@ -327,7 +327,7 @@ static int start_daemon(int fd) int daemon_main(void) { - log_open(); + extern char *config_file; if (is_a_socket(STDIN_FILENO)) { /* we are running via inetd */ @@ -336,6 +336,13 @@ int daemon_main(void) become_daemon(); + if (!lp_load(config_file, 1)) { + fprintf(stderr,"failed to load config file %s\n", config_file); + exit_cleanup(1); + } + + log_open(); + rprintf(FINFO,"rsyncd version %s starting\n",VERSION); start_accept_loop(rsync_port, start_daemon); diff --git a/loadparm.c b/loadparm.c index bf764d5e..482b41ba 100644 --- a/loadparm.c +++ b/loadparm.c @@ -253,6 +253,7 @@ Initialise the global parameter structure. ***************************************************************************/ static void init_globals(void) { + memset(&Globals, 0, sizeof(Globals)); #ifdef LOG_DAEMON Globals.syslog_facility = LOG_DAEMON; #endif @@ -664,26 +665,26 @@ static BOOL do_section(char *sectionname) Load the services array from the services file. Return True on success, False on failure. ***************************************************************************/ -BOOL lp_load(char *pszFname) +BOOL lp_load(char *pszFname, int globals_only) { - pstring n2; - BOOL bRetval; + pstring n2; + BOOL bRetval; - bRetval = False; + bRetval = False; - bInGlobalSection = True; + bInGlobalSection = True; - init_globals(); + init_globals(); - pstrcpy(n2,pszFname); + pstrcpy(n2,pszFname); - /* We get sections first, so have to start 'behind' to make up */ - iServiceIndex = -1; - bRetval = pm_process(n2, do_section, do_parameter); + /* We get sections first, so have to start 'behind' to make up */ + iServiceIndex = -1; + bRetval = pm_process(n2, globals_only?NULL:do_section, do_parameter); - bLoaded = True; + bLoaded = True; - return (bRetval); + return (bRetval); } diff --git a/params.c b/params.c index b89d034c..be019308 100644 --- a/params.c +++ b/params.c @@ -451,10 +451,11 @@ static BOOL Parse( FILE *InFile, break; case '[': /* Section Header. */ - if( !Section( InFile, sfunc ) ) - return( False ); - c = EatWhitespace( InFile ); - break; + if (!sfunc) return True; + if( !Section( InFile, sfunc ) ) + return( False ); + c = EatWhitespace( InFile ); + break; case '\\': /* Bogus backslash. */ c = EatWhitespace( InFile ); @@ -558,3 +559,4 @@ BOOL pm_process( char *FileName, } /* pm_process */ /* -------------------------------------------------------------------------- */ + -- 2.34.1