From 04932c05bf9b876aa059195100633e7c56dbce71 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 8 Jul 2001 13:02:16 +0000 Subject: [PATCH] Fix the loading of configuration files using the include syntax. We had a problem where if a % macro in the smb.conf could be ignored if the various files it pointed to had the same time-stamp. This changes the code to insted check that the both the time-stamp and the substituted filename are the same over each change. This was picked up only becouse the build-farm automaticly generates its config files, and hence gets identical timestamps. (Why this doesn't happen all the time I'm not entirly sure, somthing to do with the 'test' paramater to reload_services(), but this fixes this problem). Andrew Bartlett (This used to be commit ebd2f9b07c89cce505e821f1caaa6817bbb26db9) --- source3/param/loadparm.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 7df701e1d30..9a41060f3f2 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -2083,6 +2083,7 @@ static struct file_lists { struct file_lists *next; char *name; + char *subfname; time_t modtime; } *file_lists = NULL; @@ -2091,7 +2092,7 @@ static struct file_lists keep a linked list of all config files so we know when one has changed it's date and needs to be reloaded ********************************************************************/ -static void add_to_file_list(char *fname) +static void add_to_file_list(char *fname, char *subfname) { struct file_lists *f = file_lists; @@ -2114,15 +2115,16 @@ static void add_to_file_list(char *fname) free(f); return; } + f->subfname = strdup(subfname); + if (!f->subfname) + { + free(f); + return; + } file_lists = f; } - { - pstring n2; - pstrcpy(n2, fname); - standard_sub_basic(n2); - f->modtime = file_modtime(n2); - } + f->modtime = file_modtime(subfname); } @@ -2147,12 +2149,14 @@ BOOL lp_file_list_changed(void) mod_time = file_modtime(n2); - if (f->modtime != mod_time) + if ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0)) { DEBUGADD(6, ("file %s modified: %s\n", n2, ctime(&mod_time))); f->modtime = mod_time; + free(f->subfname); + f->subfname = strdup(n2); return (True); } f = f->next; @@ -2312,10 +2316,10 @@ static BOOL handle_include(char *pszParmValue, char **ptr) pstring fname; pstrcpy(fname, pszParmValue); - add_to_file_list(fname); - standard_sub_basic(fname); + add_to_file_list(pszParmValue, fname); + string_set(ptr, fname); if (file_exist(fname, NULL)) @@ -2785,7 +2789,7 @@ static BOOL do_section(char *pszSectionName) /*************************************************************************** -determine if a partcular base parameter is currently set to the default value. +determine if a partcular base parameter is currentl set to the default value. ***************************************************************************/ static BOOL is_default(int i) { @@ -3191,7 +3195,10 @@ BOOL lp_load(char *pszFname, BOOL global_only, BOOL save_defaults, pstring n2; BOOL bRetval; - add_to_file_list(pszFname); + pstrcpy(n2, pszFname); + standard_sub_basic(n2); + + add_to_file_list(pszFname, n2); bRetval = False; @@ -3206,9 +3213,6 @@ BOOL lp_load(char *pszFname, BOOL global_only, BOOL save_defaults, lp_save_defaults(); } - pstrcpy(n2, pszFname); - standard_sub_basic(n2); - /* We get sections first, so have to start 'behind' to make up */ iServiceIndex = -1; bRetval = pm_process(n2, do_section, do_parameter);