summaryrefslogtreecommitdiffstats
path: root/source3/param
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2014-04-17 13:48:24 +1200
committerMichael Adam <obnox@samba.org>2014-07-31 08:17:11 +0200
commit0796dc6fe009ec5305f1e748f00a1f305080e10d (patch)
tree4724f00524adbfb56550a0004644481b4135f60c /source3/param
parentadeb284a7f397ad2d730d276e56809dc5d4d1b41 (diff)
downloadsamba-0796dc6fe009ec5305f1e748f00a1f305080e10d.tar.gz
samba-0796dc6fe009ec5305f1e748f00a1f305080e10d.tar.xz
samba-0796dc6fe009ec5305f1e748f00a1f305080e10d.zip
s3:param: move all lp context setup to a single function
Change-Id: Ife53e3946a4958d81cbe892bc554520561058c65 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/loadparm.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index dd56419bf4..89d3fece21 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -919,6 +919,26 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
apply_lp_set_cmdline();
}
+/* Convenience routine to setup an lp_context with additional s3 variables */
+static struct loadparm_context *setup_lp_context(TALLOC_CTX *mem_ctx)
+{
+ struct loadparm_context *lp_ctx;
+
+ lp_ctx = loadparm_init_s3(mem_ctx,
+ loadparm_s3_helpers());
+ if (lp_ctx == NULL) {
+ DEBUG(0, ("loadparm_init_s3 failed\n"));
+ return NULL;
+ }
+
+ 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;
+
+ return lp_ctx;
+}
+
/*******************************************************************
Convenience routine to grab string parameters into talloced memory
and run standard_sub_basic on them. The buffers can be written to by
@@ -2412,19 +2432,12 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
struct loadparm_context *lp_ctx;
bool ok;
- lp_ctx = loadparm_init_s3(frame,
- loadparm_s3_helpers());
+ lp_ctx = setup_lp_context(frame);
if (lp_ctx == NULL) {
- DEBUG(0, ("loadparm_init_s3 failed\n"));
TALLOC_FREE(frame);
return false;
}
- 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;
-
if (snum < 0) {
ok = lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue);
} else {
@@ -2486,9 +2499,9 @@ bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
TALLOC_CTX *frame = talloc_stackframe();
struct loadparm_context *lp_ctx;
- lp_ctx = loadparm_init_s3(talloc_tos(), loadparm_s3_helpers());
+ lp_ctx = setup_lp_context(frame);
if (lp_ctx == NULL) {
- DEBUG(0, ("loadparm_init_s3 failed\n"));
+ TALLOC_FREE(frame);
return false;
}
@@ -2618,10 +2631,9 @@ bool lp_do_section(const char *pszSectionName, void *userdata)
bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
{
bool result = false;
-
struct loadparm_context *lp_ctx;
- lp_ctx = loadparm_init_s3(talloc_tos(), loadparm_s3_helpers());
+ lp_ctx = setup_lp_context(talloc_tos());
if (lp_ctx == NULL) {
return false;
}
@@ -3652,11 +3664,7 @@ static bool lp_load_ex(const char *pszFname,
bGlobalOnly = global_only;
bAllowIncludeRegistry = allow_include_registry;
- lp_ctx = loadparm_init_s3(talloc_tos(),
- loadparm_s3_helpers());
-
- lp_ctx->sDefault = &sDefault;
- lp_ctx->bInGlobalSection = bInGlobalSection;
+ lp_ctx = setup_lp_context(talloc_tos());
init_globals(lp_ctx, initialize_globals);
@@ -3914,16 +3922,11 @@ void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
if (show_defaults)
defaults_saved = false;
- lp_ctx = loadparm_init_s3(talloc_tos(),
- loadparm_s3_helpers());
+ lp_ctx = setup_lp_context(talloc_tos());
if (lp_ctx == NULL) {
- DEBUG(0, ("loadparm_init_s3 failed\n"));
return;
}
- lp_ctx->sDefault = &sDefault;
- lp_ctx->services = ServicePtrs;
-
lpcfg_dump_globals(lp_ctx, f, !defaults_saved);
lpcfg_dump_a_service(&sDefault, &sDefault, f, flags_list, show_defaults);