s4-param Don't set variables such as the debuglevel unless global
authorAndrew Bartlett <abartlet@samba.org>
Sun, 8 May 2011 08:30:36 +0000 (10:30 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 8 May 2011 08:56:28 +0000 (10:56 +0200)
This ensures that when a second lp_ctx is created, that it does not
set global variables such as the debug level, log file etc,
potentially overriding the settings created by another context.

In particular this matters when loading Samba4 modules into Samba3.

Andrew Bartlett

source4/param/loadparm.c

index 79706b4f09bf3d51561c91a0a0d61c60311d8eaa..ca87870c722ae3bd809121bc38c5d702234b7bc9 100644 (file)
@@ -533,6 +533,8 @@ struct loadparm_context {
        unsigned int flags[NUMPARAMETERS];
        bool loaded;
        bool refuse_free;
+       bool global; /* Is this the global context, which may set
+                     * global variables such as debug level etc? */
 };
 
 
@@ -1550,14 +1552,19 @@ static bool handle_debuglevel(struct loadparm_context *lp_ctx,
 {
 
        string_set(lp_ctx, ptr, pszParmValue);
-       return debug_parse_levels(pszParmValue);
+       if (lp_ctx->global) {
+               return debug_parse_levels(pszParmValue);
+       }
+       return true;
 }
 
 static bool handle_logfile(struct loadparm_context *lp_ctx,
                        const char *pszParmValue, char **ptr)
 {
        debug_set_logfile(pszParmValue);
-       string_set(lp_ctx, ptr, pszParmValue);
+       if (lp_ctx->global) {
+               string_set(lp_ctx, ptr, pszParmValue);
+       }
        return true;
 }
 
@@ -2561,6 +2568,7 @@ struct loadparm_context *loadparm_init_global(bool load_default)
        if (global_loadparm_context == NULL) {
                return NULL;
        }
+       global_loadparm_context->global = true;
        if (load_default && !global_loadparm_context->loaded) {
                lpcfg_load_default(global_loadparm_context);
        }
@@ -2594,6 +2602,10 @@ static bool lpcfg_update(struct loadparm_context *lp_ctx)
                lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
        }
 
+       if (!lp_ctx->global) {
+               return true;
+       }
+
        panic_action = lp_ctx->globals->panic_action;
 
        reload_charcnv(lp_ctx);
@@ -2818,6 +2830,10 @@ struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx)
 _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
 {
        struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle;
+       if (!lp_ctx->global) {
+               return;
+       }
+
        if (old_ic == NULL) {
                old_ic = global_iconv_handle;
        }