load just the globals section of the config file when the daemon
authorAndrew Tridgell <tridge@samba.org>
Fri, 15 May 1998 10:52:54 +0000 (10:52 +0000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 15 May 1998 10:52:54 +0000 (10:52 +0000)
starts so we know the syslog facility for the "starting" message

clientserver.c
loadparm.c
params.c

index 9cac2ef..121252b 100644 (file)
@@ -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);
index bf764d5..482b41b 100644 (file)
@@ -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);
 }
 
 
index b89d034..be01930 100644 (file)
--- 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 */
 
 /* -------------------------------------------------------------------------- */
+