param: Add non-global smb.cfg option (support 2 different smb.confs)
[nivanova/samba-autobuild/.git] / lib / param / loadparm.c
index 3b7f8053e4aeba3f74798a71047e1ed2b4cb77e9..9684a52952b070753b71087bdf24c5570493426b 100644 (file)
@@ -3148,7 +3148,8 @@ bool lpcfg_load_default(struct loadparm_context *lp_ctx)
  *
  * Return True on success, False on failure.
  */
  *
  * 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;
 {
        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);
 
           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);
                /* 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;
 }
 
        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.
  */
 /**
  * Return the max number of services.
  */