Bugfix for 2.2.2? Loading included files with identical times

Andrew Bartlett abartlet at pcug.org.au
Fri Sep 28 02:01:33 GMT 2001


Could/should this patch make it into 2.2.2?  

Its been running in head for quite a while, and is needed when files
being included into smb.conf have identical time-stamps.  This happens
on the build farm for one.

Original commit message and patch attached:

--

Revision 1.313 / (download) - annotate - [select for diffs] , Sun Jul 8
13:02:16 2001 UTC (2 months, 2 weeks ago) by abartlet
Branch: MAIN
Changes since 1.312: +19 -15 lines
Diff to previous 1.312 (colored)

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


-- 
Andrew Bartlett                                 abartlet at pcug.org.au
Samba Team member, Build Farm maintainer        abartlet at samba.org
Student Network Administrator, Hawker College   abartlet at hawkerc.net
http://samba.org     http://build.samba.org     http://hawkerc.net
-------------- next part --------------
Index: source/param/loadparm.c
===================================================================
RCS file: /data/cvs/samba/source/param/loadparm.c,v
retrieving revision 1.251.2.70
diff -u -r1.251.2.70 loadparm.c
--- source/param/loadparm.c	26 Sep 2001 17:19:51 -0000	1.251.2.70
+++ source/param/loadparm.c	28 Sep 2001 08:56:05 -0000
@@ -2157,6 +2157,7 @@
 {
 	struct file_lists *next;
 	char *name;
+	char *subfname;
 	time_t modtime;
 }
  *file_lists = NULL;
@@ -2165,7 +2166,7 @@
 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;
 
@@ -2188,15 +2189,16 @@
 			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);
 
 }
 
@@ -2221,12 +2223,14 @@
 
 		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;
@@ -2452,10 +2456,10 @@
 	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))
@@ -2922,7 +2926,7 @@
 
 
 /***************************************************************************
-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)
 {
@@ -3322,7 +3326,10 @@
 	pstring n2;
 	BOOL bRetval;
 
-	add_to_file_list(pszFname);
+	pstrcpy(n2, pszFname);
+	standard_sub_basic(n2);
+
+	add_to_file_list(pszFname, n2);
 
 	bRetval = False;
 
@@ -3336,9 +3343,6 @@
 		init_locals();
 		lp_save_defaults();
 	}
-
-	pstrcpy(n2, pszFname);
-	standard_sub_basic(n2);
 
 	/* We get sections first, so have to start 'behind' to make up */
 	iServiceIndex = -1;


More information about the samba-technical mailing list