diff options
author | Ralph Boehme <slow@samba.org> | 2017-11-21 14:28:48 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2017-11-27 22:08:17 +0100 |
commit | ea4e6f95ae5c97e8570b8090ee7e7a577b49a8c3 (patch) | |
tree | 2de22473287ee07c2a9f17641bb34e343726bb4a /source3/param | |
parent | 1fc103547023aa1c880713e5b65ec164acb58b54 (diff) | |
download | samba-ea4e6f95ae5c97e8570b8090ee7e7a577b49a8c3.tar.gz |
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>
Diffstat (limited to 'source3/param')
-rw-r--r-- | source3/param/loadparm.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 433727b3f79..bb6b128604e 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -111,7 +111,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; @@ -975,7 +981,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; @@ -3865,6 +3871,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()); |