From: Ralph Boehme Date: Tue, 21 Nov 2017 13:28:48 +0000 (+0100) Subject: s3/loadparm: ensure default service options are not changed X-Git-Tag: samba-4.6.12~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0a08bdf49d2c3d07f70685bf6bf4404f0e4e119;p=thirdparty%2Fsamba.git s3/loadparm: ensure default service options are not changed Rename sDefault to _sDefault and make it const. sDefault is make a copy of _sDefault in in the initialisation function lp_load_ex(). As we may end up in setup_lp_context() without going through lp_load_ex(), sDefault may still be uninitialized at that point, so I'm initializing lp_ctx->sDefault from _sDefault. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13051 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit ea4e6f95ae5c97e8570b8090ee7e7a577b49a8c3) --- diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index bc82d54fc48..3000ef713d7 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -110,7 +110,7 @@ static bool defaults_saved = false; static struct loadparm_global Globals; /* This is a default service used to prime a services structure */ -static struct loadparm_service sDefault = +static const struct loadparm_service _sDefault = { .valid = true, .autoloaded = false, @@ -249,6 +249,12 @@ static struct loadparm_service sDefault = .dummy = "" }; +/* + * This is a copy of the default service structure. Service options in the + * global section would otherwise overwrite the initial default values. + */ +static struct loadparm_service sDefault; + /* local variables */ static struct loadparm_service **ServicePtrs = NULL; static int iNumServices = 0; @@ -956,7 +962,7 @@ static struct loadparm_context *setup_lp_context(TALLOC_CTX *mem_ctx) return NULL; } - *lp_ctx->sDefault = sDefault; + *lp_ctx->sDefault = _sDefault; lp_ctx->services = NULL; /* We do not want to access this directly */ lp_ctx->bInGlobalSection = bInGlobalSection; lp_ctx->flags = flags_list; @@ -3826,6 +3832,7 @@ static bool lp_load_ex(const char *pszFname, bInGlobalSection = true; bGlobalOnly = global_only; bAllowIncludeRegistry = allow_include_registry; + sDefault = _sDefault; lp_ctx = setup_lp_context(talloc_tos());