summaryrefslogtreecommitdiff
path: root/lib/param
diff options
context:
space:
mode:
authorAaron Haslett <aaronhaslett@catalyst.net.nz>2018-05-01 11:10:36 +1200
committerAndrew Bartlett <abartlet@samba.org>2018-06-28 03:34:27 +0200
commit5728867ddcc4487bde53a11cf865563b59624eb1 (patch)
tree2507d4395f7be1fe0b083506d232dad49e6db2ff /lib/param
parentf0aad4a18736cbcbb3c87dd03cf24ae190fe8b4f (diff)
downloadsamba-5728867ddcc4487bde53a11cf865563b59624eb1.tar.gz
param: Add non-global smb.cfg option (support 2 different smb.confs)
The default behaviour is that there is only a single global underlying LoadParm object. E.g. if you create 2 different LoadParm objects in python, they both modify the same underlying object. This patch adds a mechanism to override this and create a separate non-global LoadParm object. The use-case is the backup tool, where we want to manipulate 2 different smb.conf files (the one used to create the backup, and the smb.conf in the backup itself). Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/param')
-rw-r--r--lib/param/loadparm.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 3b7f8053e4a..9684a52952b 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -3148,7 +3148,8 @@ bool lpcfg_load_default(struct loadparm_context *lp_ctx)
*
* Return True on success, False on failure.
*/
-bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
+static bool lpcfg_load_internal(struct loadparm_context *lp_ctx,
+ const char *filename, bool set_global)
{
char *n2;
bool bRetval;
@@ -3183,7 +3184,7 @@ bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
for a missing smb.conf */
reload_charcnv(lp_ctx);
- if (bRetval == true) {
+ if (bRetval == true && set_global) {
/* set this up so that any child python tasks will
find the right smb.conf */
setenv("SMB_CONF_PATH", filename, 1);
@@ -3197,6 +3198,16 @@ bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
return bRetval;
}
+bool lpcfg_load_no_global(struct loadparm_context *lp_ctx, const char *filename)
+{
+ return lpcfg_load_internal(lp_ctx, filename, false);
+}
+
+bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
+{
+ return lpcfg_load_internal(lp_ctx, filename, true);
+}
+
/**
* Return the max number of services.
*/