1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2017-11-21 14:28:48 +01:00 committed by Jeremy Allison
parent 1fc1035470
commit ea4e6f95ae

View File

@ -111,7 +111,7 @@ static bool defaults_saved = false;
static struct loadparm_global Globals; static struct loadparm_global Globals;
/* This is a default service used to prime a services structure */ /* This is a default service used to prime a services structure */
static struct loadparm_service sDefault = static const struct loadparm_service _sDefault =
{ {
.valid = true, .valid = true,
.autoloaded = false, .autoloaded = false,
@ -249,6 +249,12 @@ static struct loadparm_service sDefault =
.dummy = "" .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 */ /* local variables */
static struct loadparm_service **ServicePtrs = NULL; static struct loadparm_service **ServicePtrs = NULL;
static int iNumServices = 0; static int iNumServices = 0;
@ -975,7 +981,7 @@ static struct loadparm_context *setup_lp_context(TALLOC_CTX *mem_ctx)
return NULL; return NULL;
} }
*lp_ctx->sDefault = sDefault; *lp_ctx->sDefault = _sDefault;
lp_ctx->services = NULL; /* We do not want to access this directly */ lp_ctx->services = NULL; /* We do not want to access this directly */
lp_ctx->bInGlobalSection = bInGlobalSection; lp_ctx->bInGlobalSection = bInGlobalSection;
lp_ctx->flags = flags_list; lp_ctx->flags = flags_list;
@ -3865,6 +3871,7 @@ static bool lp_load_ex(const char *pszFname,
bInGlobalSection = true; bInGlobalSection = true;
bGlobalOnly = global_only; bGlobalOnly = global_only;
bAllowIncludeRegistry = allow_include_registry; bAllowIncludeRegistry = allow_include_registry;
sDefault = _sDefault;
lp_ctx = setup_lp_context(talloc_tos()); lp_ctx = setup_lp_context(talloc_tos());