From 9fa02847b7c07ec3b1136261d54bbed7706dd0af Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 10 Mar 2008 17:16:01 +0100 Subject: loadparm: fix init_globals() to re-init all options event when called 2nd time. Up to the globals had only been fully reset when init_globals() was called for the first time. But a full restart is needed for use with "config backend = registry". (And should be with "config file = ...", but in this case the restart is outsourced to the daemons.) This left some options (like e.g. "realm") set to values that were set in smb.conf before the occurence of "config backend = registry". Now this misbehaviour is fixed with this change. Michael (This used to be commit f12259d9c4c34b99f5b655cab4b210159cb0e188) --- source3/param/loadparm.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index d17fa16cbb..aaeafac21e 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -4535,6 +4535,7 @@ static void init_globals(bool first_time_only) { static bool done_init = False; char *s = NULL; + int i; /* If requested to initialize only once and we've already done it... */ if (first_time_only && done_init) { @@ -4543,30 +4544,39 @@ static void init_globals(bool first_time_only) } if (!done_init) { - int i; - /* The logfile can be set before this is invoked. Free it if so. */ if (Globals.szLogFile != NULL) { string_free(&Globals.szLogFile); Globals.szLogFile = NULL; } - - memset((void *)&Globals, '\0', sizeof(Globals)); - - for (i = 0; parm_table[i].label; i++) + done_init = True; + } else { + for (i = 0; parm_table[i].label; i++) { if ((parm_table[i].type == P_STRING || parm_table[i].type == P_USTRING) && parm_table[i].ptr) - string_set((char **)parm_table[i].ptr, ""); - - string_set(&sDefault.fstype, FSTYPE_STRING); - string_set(&sDefault.szPrintjobUsername, "%U"); + { + string_free((char **)parm_table[i].ptr); + } + } + } - init_printer_values(&sDefault); + memset((void *)&Globals, '\0', sizeof(Globals)); - done_init = True; + for (i = 0; parm_table[i].label; i++) { + if ((parm_table[i].type == P_STRING || + parm_table[i].type == P_USTRING) && + parm_table[i].ptr) + { + string_set((char **)parm_table[i].ptr, ""); + } } + string_set(&sDefault.fstype, FSTYPE_STRING); + string_set(&sDefault.szPrintjobUsername, "%U"); + + init_printer_values(&sDefault); + DEBUG(3, ("Initialising global parameters\n")); -- cgit