summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/client/client.c4
-rw-r--r--source3/client/smbmount.c8
-rw-r--r--source3/client/smbspool.c4
-rw-r--r--source3/dynconfig.c251
-rw-r--r--source3/include/dynconfig.h51
-rw-r--r--source3/lib/fault.c2
-rw-r--r--source3/lib/ldb/common/ldb_modules.c2
-rw-r--r--source3/lib/pidfile.c8
-rw-r--r--source3/lib/popt_common.c26
-rw-r--r--source3/lib/util.c10
-rw-r--r--source3/libsmb/libsmbclient.c6
-rw-r--r--source3/libsmb/namequery.c2
-rw-r--r--source3/nmbd/nmbd.c17
-rw-r--r--source3/nmbd/nmbd_winsserver.c2
-rw-r--r--source3/nsswitch/wbinfo.c4
-rw-r--r--source3/nsswitch/wins.c2
-rw-r--r--source3/pam_smbpass/support.c4
-rw-r--r--source3/param/loadparm.c10
-rw-r--r--source3/passdb/pdb_tdb.c2
-rw-r--r--source3/rpc_client/cli_pipe.c2
-rw-r--r--source3/rpc_server/srv_srvsvc_nt.c6
-rw-r--r--source3/rpcclient/rpcclient.c4
-rw-r--r--source3/services/services_db.c6
-rw-r--r--source3/services/svc_rcinit.c6
-rw-r--r--source3/smbd/lanman.c2
-rw-r--r--source3/smbd/server.c6
-rw-r--r--source3/torture/locktest.c2
-rw-r--r--source3/torture/locktest2.c2
-rw-r--r--source3/torture/masktest.c2
-rw-r--r--source3/torture/msgtest.c2
-rw-r--r--source3/torture/pdbtest.c2
-rw-r--r--source3/torture/torture.c2
-rw-r--r--source3/torture/vfstest.c6
-rw-r--r--source3/utils/eventlogadm.c2
-rw-r--r--source3/utils/net.c2
-rw-r--r--source3/utils/net_ads.c8
-rw-r--r--source3/utils/nmblookup.c4
-rw-r--r--source3/utils/ntlm_auth.c4
-rw-r--r--source3/utils/pdbedit.c4
-rw-r--r--source3/utils/sharesec.c2
-rw-r--r--source3/utils/smbcacls.c2
-rw-r--r--source3/utils/smbcontrol.c2
-rw-r--r--source3/utils/smbcquotas.c2
-rw-r--r--source3/utils/smbfilter.c2
-rw-r--r--source3/utils/smbpasswd.c2
-rw-r--r--source3/utils/smbtree.c2
-rw-r--r--source3/utils/smbw_sample.c4
-rw-r--r--source3/utils/status.c6
-rw-r--r--source3/utils/testparm.c2
-rw-r--r--source3/web/startstop.c6
-rw-r--r--source3/web/swat.c18
-rw-r--r--source3/winbindd/idmap.c2
-rw-r--r--source3/winbindd/winbindd.c8
-rw-r--r--source3/winbindd/winbindd_cm.c2
-rw-r--r--source3/winbindd/winbindd_dual.c4
55 files changed, 406 insertions, 149 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 80e906df5a..d59af9e6cf 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -4705,9 +4705,9 @@ static int do_message_op(void)
if ( override_logfile )
setup_logging( lp_logfile(), false );
- if (!lp_load(dyn_CONFIGFILE,true,false,false,true)) {
+ if (!lp_load(get_dyn_CONFIGFILE(),true,false,false,true)) {
fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n",
- argv[0], dyn_CONFIGFILE);
+ argv[0], get_dyn_CONFIGFILE());
}
load_interfaces();
diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c
index 2e8d554721..98c61a30d8 100644
--- a/source3/client/smbmount.c
+++ b/source3/client/smbmount.c
@@ -535,7 +535,7 @@ static void init_mount(void)
if (sys_fork() == 0) {
char *smbmnt_path;
- asprintf(&smbmnt_path, "%s/smbmnt", dyn_BINDIR);
+ asprintf(&smbmnt_path, "%s/smbmnt", get_dyn_BINDIR());
if (file_exist(smbmnt_path, NULL)) {
execv(smbmnt_path, (char * const *)args);
@@ -586,7 +586,7 @@ static void get_password_file(void)
int fd = -1;
char *p;
bool close_it = False;
- char *spec;
+ char *spec = NULL;
TALLOC_CTX *ctx = talloc_tos();
char pass[128];
@@ -1012,9 +1012,9 @@ static void parse_mount_smb(int argc, char **argv)
}
}
- if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
+ if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
- dyn_CONFIGFILE);
+ get_dyn_CONFIGFILE());
}
parse_mount_smb(argc, argv);
diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
index 0ba4d57ff5..4270eb4272 100644
--- a/source3/client/smbspool.c
+++ b/source3/client/smbspool.c
@@ -230,9 +230,9 @@ static char * uri_unescape_alloc(const char *);
load_case_tables();
- if (!lp_load(dyn_CONFIGFILE, True, False, False, True))
+ if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, True))
{
- fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
+ fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE());
goto done;
}
diff --git a/source3/dynconfig.c b/source3/dynconfig.c
index c9dcea5204..ab0dd48da7 100644
--- a/source3/dynconfig.c
+++ b/source3/dynconfig.c
@@ -1,18 +1,19 @@
-/*
+/*
Unix SMB/CIFS implementation.
Copyright (C) 2001 by Martin Pool <mbp@samba.org>
Copyright (C) 2003 by Jim McDonough <jmcd@us.ibm.com>
-
+ Copyright (C) 2007 by Jeremy Allison <jra@samba.org>
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -39,52 +40,262 @@
* table? There's kind of a chicken-and-egg situation there...
**/
-char const *dyn_SBINDIR = SBINDIR,
- *dyn_BINDIR = BINDIR,
- *dyn_SWATDIR = SWATDIR;
+#if 0
+static char const *dyn_SBINDIR = SBINDIR;
+static char const *dyn_BINDIR = BINDIR;
+static char const *dyn_SWATDIR = SWATDIR;
+#endif
+
+#define DEFINE_DYN_CONFIG_PARAM(name) \
+static char *dyn_##name; \
+\
+ const char *get_dyn_##name(void) \
+{\
+ if (dyn_##name == NULL) {\
+ return name;\
+ }\
+ return dyn_##name;\
+}\
+\
+ const char *set_dyn_##name(const char *newpath) \
+{\
+ if (dyn_##name) {\
+ SAFE_FREE(dyn_##name);\
+ }\
+ dyn_##name = SMB_STRDUP(newpath);\
+ return dyn_##name;\
+}
+
+DEFINE_DYN_CONFIG_PARAM(SBINDIR)
+DEFINE_DYN_CONFIG_PARAM(BINDIR)
+DEFINE_DYN_CONFIG_PARAM(SWATDIR)
+DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/
+DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/
+DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/
+DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR)
+DEFINE_DYN_CONFIG_PARAM(LIBDIR)
+DEFINE_DYN_CONFIG_PARAM(SHLIBEXT)
+DEFINE_DYN_CONFIG_PARAM(LOCKDIR)
+DEFINE_DYN_CONFIG_PARAM(PIDDIR)
+DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE)
+DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR)
+
+#if 0
+static char *dyn_CONFIGFILE; /**< Location of smb.conf file. **/
+
+const char *get_dyn_CONFIGFILE(void)
+{
+ if (dyn_CONFIGFILE == NULL) {
+ return CONFIGFILE;
+ }
+ return dyn_CONFIGFILE;
+}
-/* JRA - FIXME - these should be dynamic char * */
-char dyn_CONFIGFILE[1024] = CONFIGFILE; /**< Location of smb.conf file. **/
+const char *set_dyn_CONFIGFILE(const char *newpath)
+{
+ if (dyn_CONFIGFILE) {
+ SAFE_FREE(dyn_CONFIGFILE);
+ }
+ dyn_CONFIGFILE = SMB_STRDUP(newpath);
+ return dyn_CONFIGFILE;
+}
/** Log file directory. **/
-char dyn_LOGFILEBASE[1024] = LOGFILEBASE;
+static char *dyn_LOGFILEBASE;
+
+const char *get_dyn_LOGFILEBASE(void)
+{
+ if (dyn_LOGFILEBASE == NULL) {
+ return LOGFILEBASE;
+ }
+ return dyn_LOGFILEBASE;
+}
+
+const char *set_dyn_LOGFILEBASE(const char *newpath)
+{
+ if (dyn_LOGFILEBASE) {
+ SAFE_FREE(dyn_LOGFILEBASE);
+ }
+ dyn_LOGFILEBASE = SMB_STRDUP(newpath);
+ return dyn_LOGFILEBASE;
+}
/** Statically configured LanMan hosts. **/
-char dyn_LMHOSTSFILE[1024] = LMHOSTSFILE;
+static char *dyn_LMHOSTSFILE;
+
+const char *get_dyn_LMHOSTSFILE(void)
+{
+ if (dyn_LMHOSTSFILE == NULL) {
+ return LMHOSTSFILE;
+ }
+ return dyn_LMHOSTSFILE;
+}
+
+const char *set_dyn_LMHOSTSFILE(const char *newpath)
+{
+ if (dyn_LMHOSTSFILE) {
+ SAFE_FREE(dyn_LMHOSTSFILE);
+ }
+ dyn_LMHOSTSFILE = SMB_STRDUP(newpath);
+ return dyn_LMHOSTSFILE;
+}
/**
* @brief Samba data directory.
*
* @sa data_path() to get the path to a file inside the CODEPAGEDIR.
**/
-char dyn_CODEPAGEDIR[1024] = CODEPAGEDIR;
+static char *dyn_CODEPAGEDIR;
+
+const char *get_dyn_CODEPAGEDIR(void)
+{
+ if (dyn_CODEPAGEDIR == NULL) {
+ return CODEPAGEDIR;
+ }
+ return dyn_CODEPAGEDIR;
+}
+
+const char *set_dyn_CODEPAGEDIR(const char *newpath)
+{
+ if (dyn_CODEPAGEDIR) {
+ SAFE_FREE(dyn_CODEPAGEDIR);
+ }
+ dyn_CODEPAGEDIR = SMB_STRDUP(newpath);
+ return dyn_CODEPAGEDIR;
+}
/**
* @brief Samba library directory.
*
* @sa lib_path() to get the path to a file inside the LIBDIR.
**/
-char dyn_LIBDIR[1024] = LIBDIR;
-fstring dyn_SHLIBEXT = SHLIBEXT;
+static char *dyn_LIBDIR;
+
+const char *get_dyn_LIBDIR(void)
+{
+ if (dyn_LIBDIR == NULL) {
+ return LIBDIR;
+ }
+ return dyn_CODEPAGEDIR;
+}
+
+const char *set_dyn_LIBDIR(const char *newpath)
+{
+ if (dyn_LIBDIR) {
+ SAFE_FREE(dyn_LIBDIR);
+ }
+ dyn_LIBDIR = SMB_STRDUP(newpath);
+ return dyn_LIBDIR;
+}
+
+static char *dyn_SHLIBEXT;
+
+const char *get_dyn_SHLIBEXT(void)
+{
+ if (dyn_SHLIBEXT == NULL) {
+ return SHLIBEXT;
+ }
+ return dyn_SHLIBEXT;
+}
+
+const char *set_dyn_SHLIBEXT(const char *newpath)
+{
+ if (dyn_SHLIBEXT) {
+ SAFE_FREE(dyn_SHLIBEXT);
+ }
+ dyn_SHLIBEXT = SMB_STRDUP(newpath);
+ return dyn_SHLIBEXT;
+}
/**
* @brief Directory holding lock files.
*
* Not writable, but used to set a default in the parameter table.
**/
-char dyn_LOCKDIR[1024] = LOCKDIR;
-char dyn_PIDDIR[1024] = PIDDIR;
-char dyn_SMB_PASSWD_FILE[1024] = SMB_PASSWD_FILE;
-char dyn_PRIVATE_DIR[1024] = PRIVATE_DIR;
+static char *dyn_LOCKDIR;
+
+const char *get_dyn_LOCKDIR(void)
+{
+ if (dyn_LOCKDIR == NULL) {
+ return LOCKDIR;
+ }
+ return dyn_LOCKDIR;
+}
+
+const char *set_dyn_LOCKDIR(const char *newpath)
+{
+ if (dyn_LOCKDIR) {
+ SAFE_FREE(dyn_LOCKDIR);
+ }
+ dyn_LOCKDIR = SMB_STRDUP(newpath);
+ return dyn_LOCKDIR;
+}
+
+static char *dyn_PIDDIR;
+
+const char *get_dyn_PIDDIR(void)
+{
+ if (dyn_PIDDIR == NULL) {
+ return PIDDIR;
+ }
+ return dyn_PIDDIR;
+}
+const char *set_dyn_PIDDIR(const char *newpath)
+{
+ if (dyn_PIDDIR) {
+ SAFE_FREE(dyn_PIDDIR);
+ }
+ dyn_PIDDIR = SMB_STRDUP(newpath);
+ return dyn_PIDDIR;
+}
+
+static char *dyn_SMB_PASSWD_FILE;
+
+const char *get_dyn_SMB_PASSWD_FILE(void)
+{
+ if (dyn_SMB_PASSWD_FILE == NULL) {
+ return SMB_PASSWD_FILE;
+ }
+ return dyn_SMB_PASSWD_FILE;
+}
+
+const char *set_dyn_SMB_PASSWD_FILE(const char *newpath)
+{
+ if (dyn_SMB_PASSWD_FILE) {
+ SAFE_FREE(dyn_SMB_PASSWD_FILE);
+ }
+ dyn_SMB_PASSWD_FILE = SMB_STRDUP(newpath);
+ return dyn_SMB_PASSWD_FILE;
+}
+
+static char *dyn_PRIVATE_DIR;
+
+const char *get_dyn_PRIVATE_DIR(void)
+{
+ if (dyn_PRIVATE_DIR == NULL) {
+ return PRIVATE_DIR;
+ }
+ return dyn_PRIVATE_DIR;
+}
+
+const char *set_dyn_PRIVATE_DIR(const char *newpath)
+{
+ if (dyn_PRIVATE_DIR) {
+ SAFE_FREE(dyn_PRIVATE_DIR);
+ }
+ dyn_PRIVATE_DIR = SMB_STRDUP(newpath);
+ return dyn_PRIVATE_DIR;
+}
+#endif
/* In non-FHS mode, these should be configurable using 'lock dir =';
but in FHS mode, they are their own directory. Implement as wrapper
functions so that everything can still be kept in dynconfig.c.
*/
-char *dyn_STATEDIR(void)
+const char *get_dyn_STATEDIR(void)
{
#ifdef FHS_COMPATIBLE
return STATEDIR;
@@ -93,7 +304,7 @@ char *dyn_STATEDIR(void)
#endif
}
-char *dyn_CACHEDIR(void)
+const char *get_dyn_CACHEDIR(void)
{
#ifdef FHS_COMPATIBLE
return CACHEDIR;
diff --git a/source3/include/dynconfig.h b/source3/include/dynconfig.h
index a26f840f66..bb7e2c20f4 100644
--- a/source3/include/dynconfig.h
+++ b/source3/include/dynconfig.h
@@ -23,9 +23,10 @@
* @brief Exported global configurations.
**/
-extern char const *dyn_SBINDIR,
- *dyn_BINDIR,
- *dyn_SWATDIR;
+#if 0
+const char *get_dyn_SBINDIR(void);
+const char *get_dyn_BINDIR(void);
+const char *get_dyn_SWATDIR(void);
extern char dyn_CONFIGFILE[1024];
extern char dyn_LOGFILEBASE[1024], dyn_LMHOSTSFILE[1024];
@@ -36,6 +37,46 @@ extern char dyn_LOCKDIR[1024];
extern char dyn_PIDDIR[1024];
extern char dyn_SMB_PASSWD_FILE[1024];
extern char dyn_PRIVATE_DIR[1024];
+#endif
-char *dyn_STATEDIR(void);
-char *dyn_CACHEDIR(void);
+const char *get_dyn_SBINDIR(void);
+const char *set_dyn_SBINDIR(const char *newpath);
+
+const char *get_dyn_BINDIR(void);
+const char *set_dyn_BINDIR(const char *newpath);
+
+const char *get_dyn_SWATDIR(void);
+const char *set_dyn_SWATDIR(const char *newpath);
+
+const char *get_dyn_CONFIGFILE(void);
+const char *set_dyn_CONFIGFILE(const char *newpath);
+
+const char *get_dyn_dyn_LOGFILEBASE(void);
+const char *set_dyn_dyn_LOGFILEBASE(const char *newpath);
+
+const char *get_dyn_LMHOSTSFILE(void);
+const char *set_dyn_LMHOSTSFILE(const char *newpath);
+
+const char *get_dyn_CODEPAGEDIR(void);
+const char *set_dyn_CODEPAGEDIR(const char *newpath);
+
+const char *get_dyn_LIBDIR(void);
+const char *set_dyn_LIBDIR(const char *newpath);
+
+const char *get_dyn_SHLIBEXT(void);
+const char *set_dyn_SHLIBEXT(const char *newpath);
+
+const char *get_dyn_LOCKDIR(void);
+const char *set_dyn_LOCKDIR(const char *newpath);
+
+const char *get_dyn_PIDDIR(void);
+const char *set_dyn_PIDDIR(const char *newpath);
+
+const char *get_dyn_SMB_PASSWD_FILE(void);
+const char *set_dyn_SMB_PASSWD_FILE(const char *newpath);
+
+const char *get_dyn_PRIVATE_DIR(void);
+const char *set_dyn_PRIVATE_DIR(const char *newpath);
+
+const char *get_dyn_STATEDIR(void);
+const char *get_dyn_CACHEDIR(void);
diff --git a/source3/lib/fault.c b/source3/lib/fault.c
index b5d290a2c8..33e1401d7a 100644
--- a/source3/lib/fault.c
+++ b/source3/lib/fault.c
@@ -108,7 +108,7 @@ void dump_core_setup(const char *progname)
* line by the -l option but the "log file" option is not set
* in smb.conf.
*/
- if (asprintf(&logbase, "%s", dyn_LOGFILEBASE) < 0) {
+ if (asprintf(&logbase, "%s", get_dyn_LOGFILEBASE()) < 0) {
return;
}
}
diff --git a/source3/lib/ldb/common/ldb_modules.c b/source3/lib/ldb/common/ldb_modules.c
index c2fec2aea8..68c4535e4d 100644
--- a/source3/lib/ldb/common/ldb_modules.c
+++ b/source3/lib/ldb/common/ldb_modules.c
@@ -212,7 +212,7 @@ int ldb_try_load_dso(struct ldb_context *ldb, const char *name)
modulesdir = talloc_strdup(ldb, getenv("LD_LDB_MODULE_PATH"));
} else {
#ifdef _SAMBA_BUILD_
- modulesdir = talloc_asprintf(ldb, "%s/ldb", dyn_MODULESDIR);
+ modulesdir = talloc_asprintf(ldb, "%s/ldb", get_dyn_LIBDIR());
#else
modulesdir = talloc_strdup(ldb, MODULESDIR);
#endif
diff --git a/source3/lib/pidfile.c b/source3/lib/pidfile.c
index b6a8e02b49..f49f8afbb6 100644
--- a/source3/lib/pidfile.c
+++ b/source3/lib/pidfile.c
@@ -86,20 +86,20 @@ void pidfile_create(const char *program_name)
{
int fd;
char buf[20];
- char *short_configfile;
+ const char *short_configfile;
char *name;
char *pidFile;
pid_t pid;
/* Add a suffix to the program name if this is a process with a
* none default configuration file name. */
- if (strcmp( CONFIGFILE, dyn_CONFIGFILE) == 0) {
+ if (strcmp( CONFIGFILE, get_dyn_CONFIGFILE()) == 0) {
name = SMB_STRDUP(program_name);
} else {
- short_configfile = strrchr( dyn_CONFIGFILE, '/');
+ short_configfile = strrchr( get_dyn_CONFIGFILE(), '/');
if (short_configfile == NULL) {
/* conf file in current directory */
- short_configfile = dyn_CONFIGFILE;
+ short_configfile = get_dyn_CONFIGFILE();
} else {
/* full/relative path provided */
short_configfile++;
diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index 835eeaecc3..bc67a0fa28 100644
--- a/source3/lib/popt_common.c
+++ b/source3/lib/popt_common.c
@@ -66,7 +66,7 @@ static void popt_common_callback(poptContext con,
{
if (reason == POPT_CALLBACK_REASON_PRE) {
- set_logfile(con, dyn_LOGFILEBASE);
+ set_logfile(con, get_dyn_LOGFILEBASE());
return;
}
@@ -98,7 +98,7 @@ static void popt_common_callback(poptContext con,
case 's':
if (arg) {
- strlcpy(dyn_CONFIGFILE, arg,sizeof(dyn_CONFIGFILE));
+ set_dyn_CONFIGFILE(arg);
}
break;
@@ -112,7 +112,7 @@ static void popt_common_callback(poptContext con,
if (arg) {
set_logfile(con, arg);
override_logfile = True;
- snprintf(dyn_LOGFILEBASE, sizeof(dyn_LOGFILEBASE), "%s", arg);
+ set_dyn_LOGFILEBASE(arg);
}
break;
@@ -193,61 +193,61 @@ static void popt_dynconfig_callback(poptContext con,
switch (opt->val) {
case DYN_SBINDIR:
if (arg) {
- dyn_SBINDIR = SMB_STRDUP(arg);
+ set_dyn_SBINDIR(arg);
}
break;
case DYN_BINDIR:
if (arg) {
- dyn_BINDIR = SMB_STRDUP(arg);
+ set_dyn_BINDIR(arg);
}
break;
case DYN_SWATDIR:
if (arg) {
- dyn_SWATDIR = SMB_STRDUP(arg);
+ set_dyn_SWATDIR(arg);
}
break;
case DYN_LMHOSTSFILE:
if (arg) {
- strlcpy(dyn_LMHOSTSFILE, arg,sizeof(dyn_LMHOSTSFILE));
+ set_dyn_LMHOSTSFILE(arg);
}
break;
case DYN_LIBDIR:
if (arg) {
- strlcpy(dyn_LIBDIR, arg,sizeof(dyn_LIBDIR));
+ set_dyn_LIBDIR(arg);
}
break;
case DYN_SHLIBEXT:
if (arg) {
- fstrcpy(dyn_SHLIBEXT, arg);
+ set_dyn_SHLIBEXT(arg);
}
break;
case DYN_LOCKDIR:
if (arg) {
- strlcpy(dyn_LOCKDIR, arg,sizeof(dyn_LOCKDIR));
+ set_dyn_LOCKDIR(arg);
}
break;
case DYN_PIDDIR:
if (arg) {
- strlcpy(dyn_PIDDIR, arg,sizeof(dyn_PIDDIR));
+ set_dyn_PIDDIR(arg);
}
break;
case DYN_SMB_PASSWD_FILE:
if (arg) {
- strlcpy(dyn_SMB_PASSWD_FILE, arg,sizeof(dyn_SMB_PASSWD_FILE));
+ set_dyn_SMB_PASSWD_FILE(arg);
}
break;
case DYN_PRIVATE_DIR:
if (arg) {
- strlcpy(dyn_PRIVATE_DIR, arg, sizeof(dyn_PRIVATE_DIR));
+ set_dyn_PRIVATE_DIR(arg);
}
break;
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 83b122c660..19c3e0c65b 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2569,7 +2569,7 @@ char *pid_path(const char *name)
char *lib_path(const char *name)
{
- return talloc_asprintf(talloc_tos(), "%s/%s", dyn_LIBDIR, name);
+ return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_LIBDIR(), name);
}
/**
@@ -2582,7 +2582,7 @@ char *lib_path(const char *name)
char *data_path(const char *name)
{
- return talloc_asprintf(talloc_tos(), "%s/%s", dyn_CODEPAGEDIR, name);
+ return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_CODEPAGEDIR(), name);
}
/*****************************************************************
@@ -2591,18 +2591,18 @@ a useful function for returning a path in the Samba state directory
char *state_path(const char *name)
{
- return xx_path(name, dyn_STATEDIR());
+ return xx_path(name, get_dyn_STATEDIR());
}
/**
* @brief Returns the platform specific shared library extension.
*
- * @retval Pointer to a static #fstring containing the extension.
+ * @retval Pointer to a const char * containing the extension.
**/
const char *shlib_ext(void)
{
- return dyn_SHLIBEXT;
+ return get_dyn_SHLIBEXT();
}
/*******************************************************************
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index 9f5567576f..9b8d5edb4a 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -6900,15 +6900,15 @@ smbc_init_context(SMBCCTX *context)
if (!conf_loaded) {
/*
- * Well, if that failed, try the dyn_CONFIGFILE
+ * Well, if that failed, try the get_dyn_CONFIGFILE
* Which points to the standard locn, and if that
* fails, silently ignore it and use the internal
* defaults ...
*/
- if (!lp_load(dyn_CONFIGFILE, True, False, False, False)) {
+ if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, False)) {
DEBUG(5, ("Could not load config file: %s\n",
- dyn_CONFIGFILE));
+ get_dyn_CONFIGFILE()));
} else if (home) {
char *conf;
/*
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index e4206e6065..0decc59ed7 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -1157,7 +1157,7 @@ static NTSTATUS resolve_lmhosts(const char *name, int name_type,
"Attempting lmhosts lookup for name %s<0x%x>\n",
name, name_type));
- fp = startlmhosts(dyn_LMHOSTSFILE);
+ fp = startlmhosts(get_dyn_LMHOSTSFILE());
if ( fp == NULL )
return NT_STATUS_NO_SUCH_FILE;
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 52f1cd15f5..344831ddca 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -288,8 +288,8 @@ static bool reload_nmbd_services(bool test)
if ( lp_loaded() ) {
const char *fname = lp_configfile();
- if (file_exist(fname,NULL) && !strcsequal(fname,dyn_CONFIGFILE)) {
- strlcpy(dyn_CONFIGFILE,fname,sizeof(dyn_CONFIGFILE));
+ if (file_exist(fname,NULL) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
+ set_dyn_CONFIGFILE(fname);
test = False;
}
}
@@ -297,7 +297,7 @@ static bool reload_nmbd_services(bool test)
if ( test && !lp_file_list_changed() )
return(True);
- ret = lp_load( dyn_CONFIGFILE, True , False, False, True);
+ ret = lp_load(get_dyn_CONFIGFILE(), True , False, False, True);
/* perhaps the config filename is now set */
if ( !test ) {
@@ -710,7 +710,7 @@ static bool open_sockets(bool isdaemon, int port)
static bool no_process_group;
static bool log_stdout;
poptContext pc;
- static char *p_lmhosts = dyn_LMHOSTSFILE;
+ char *p_lmhosts = NULL;
int opt;
enum {
OPT_DAEMON = 1000,
@@ -772,7 +772,7 @@ static bool open_sockets(bool isdaemon, int port)
if (!override_logfile) {
char *logfile = NULL;
- if (asprintf(&logfile, "%s/log.nmbd", dyn_LOGFILEBASE) < 0) {
+ if (asprintf(&logfile, "%s/log.nmbd", get_dyn_LOGFILEBASE()) < 0) {
exit(1);
}
lp_set_logfile(logfile);
@@ -903,8 +903,11 @@ static bool open_sockets(bool isdaemon, int port)
}
/* Load in any static local names. */
- load_lmhosts_file(p_lmhosts);
- DEBUG(3,("Loaded hosts file %s\n", p_lmhosts));
+ if (p_lmhosts) {
+ set_dyn_LMHOSTSFILE(p_lmhosts);
+ }
+ load_lmhosts_file(get_dyn_LMHOSTSFILE());
+ DEBUG(3,("Loaded hosts file %s\n", get_dyn_LMHOSTSFILE()));
/* If we are acting as a WINS server, initialise data structures. */
if( !initialise_wins() ) {
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index 7344a29fe4..96938b011a 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -2366,7 +2366,7 @@ void wins_write_database(time_t t, bool background)
}
}
- if (asprintf(&fname, "%s/%s", dyn_STATEDIR(), WINS_LIST) < 0) {
+ if (asprintf(&fname, "%s/%s", get_dyn_STATEDIR(), WINS_LIST) < 0) {
goto err_exit;
}
/* This is safe as the 0 length means "don't expand". */
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index 481f51779f..2466af142d 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -1347,9 +1347,9 @@ int main(int argc, char **argv, char **envp)
/* Samba client initialisation */
load_case_tables();
- if (!lp_load(dyn_CONFIGFILE, True, False, False, True)) {
+ if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, True)) {
d_fprintf(stderr, "wbinfo: error opening config file %s. Error was %s\n",
- dyn_CONFIGFILE, strerror(errno));
+ get_dyn_CONFIGFILE(), strerror(errno));
exit(1);
}
diff --git a/source3/nsswitch/wins.c b/source3/nsswitch/wins.c
index 9d6273ce7b..c822fc78b9 100644
--- a/source3/nsswitch/wins.c
+++ b/source3/nsswitch/wins.c
@@ -85,7 +85,7 @@ static void nss_wins_init(void)
TimeInit();
setup_logging("nss_wins",False);
load_case_tables();
- lp_load(dyn_CONFIGFILE,True,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
}
diff --git a/source3/pam_smbpass/support.c b/source3/pam_smbpass/support.c
index 78d6441c90..9d56bd4950 100644
--- a/source3/pam_smbpass/support.c
+++ b/source3/pam_smbpass/support.c
@@ -63,7 +63,7 @@
/* default configuration file location */
- char *servicesf = dyn_CONFIGFILE;
+ const char *servicesf = get_dyn_CONFIGFILE();
/* syslogging function for errors and other information */
@@ -128,7 +128,7 @@
int set_ctrl( int flags, int argc, const char **argv )
{
int i = 0;
- const char *service_file = dyn_CONFIGFILE;
+ const char *service_file = get_dyn_CONFIGFILE();
unsigned int ctrl;
ctrl = SMB_DEFAULTS; /* the default selection of options */
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 608acb12e7..e676edf37c 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1456,8 +1456,8 @@ static void init_globals(bool first_time_only)
DEBUG(3, ("Initialising global parameters\n"));
- string_set(&Globals.szSMBPasswdFile, dyn_SMB_PASSWD_FILE);
- string_set(&Globals.szPrivateDir, dyn_PRIVATE_DIR);
+ string_set(&Globals.szSMBPasswdFile, get_dyn_SMB_PASSWD_FILE());
+ string_set(&Globals.szPrivateDir, get_dyn_PRIVATE_DIR());
/* use the new 'hash2' method by default, with a prefix of 1 */
string_set(&Globals.szManglingMethod, "hash2");
@@ -1491,8 +1491,8 @@ static void init_globals(bool first_time_only)
string_set(&Globals.szWorkgroup, lp_workgroup());
string_set(&Globals.szPasswdProgram, "");
- string_set(&Globals.szPidDir, dyn_PIDDIR);
- string_set(&Globals.szLockDir, dyn_LOCKDIR);
+ string_set(&Globals.szPidDir, get_dyn_PIDDIR());
+ string_set(&Globals.szLockDir, get_dyn_LOCKDIR());
string_set(&Globals.szSocketAddress, "0.0.0.0");
if (asprintf(&s, "Samba %s", SAMBA_VERSION_STRING) < 0) {
@@ -1701,7 +1701,7 @@ static void init_globals(bool first_time_only)
Globals.bASUSupport = False;
/* User defined shares. */
- if (asprintf(&s, "%s/usershares", dyn_STATEDIR()) < 0) {
+ if (asprintf(&s, "%s/usershares", get_dyn_STATEDIR()) < 0) {
smb_panic("init_globals: ENOMEM");
}
string_set(&Globals.szUsersharePath, s);
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index fe8497c939..b4282b1278 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -1625,7 +1625,7 @@ static NTSTATUS pdb_init_tdbsam(struct pdb_methods **pdb_method, const char *loc
/* save the path for later */
if (!location) {
- if (asprintf(&tdbfile, "%s/%s", dyn_STATEDIR(), PASSDB_FILE_NAME) < 0) {
+ if (asprintf(&tdbfile, "%s/%s", get_dyn_STATEDIR(), PASSDB_FILE_NAME) < 0) {
return NT_STATUS_NO_MEMORY;
}
pfile = tdbfile;
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 05ef2ad151..37558a7ff0 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -1555,7 +1555,7 @@ NTSTATUS rpc_api_pipe_req(struct rpc_pipe_client *cli,
char *dump_name = NULL;
/* Also capture received data */
if (asprintf(&dump_name, "%s/reply_%s_%d",
- dyn_LOGFILEBASE, cli->pipe_name,
+ get_dyn_LOGFILEBASE(), cli->pipe_name,
op_num) > 0) {
prs_dump(dump_name, op_num, out_data);
SAFE_FREE(dump_name);
diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c
index b034e7cbd3..125ccb4752 100644
--- a/source3/rpc_server/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srv_srvsvc_nt.c
@@ -1692,7 +1692,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
command = talloc_asprintf(p->mem_ctx,
"%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
lp_change_share_cmd(),
- dyn_CONFIGFILE,
+ get_dyn_CONFIGFILE(),
share_name,
path,
comment ? comment : "",
@@ -1877,7 +1877,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
command = talloc_asprintf(ctx,
"%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
lp_add_share_cmd(),
- dyn_CONFIGFILE,
+ get_dyn_CONFIGFILE(),
share_name,
path,
comment ? comment : "",
@@ -1984,7 +1984,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S
command = talloc_asprintf(ctx,
"%s \"%s\" \"%s\"",
lp_delete_share_cmd(),
- dyn_CONFIGFILE,
+ get_dyn_CONFIGFILE(),
lp_servicename(snum));
if (!command) {
return WERR_NOMEM;
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 627c821baa..6f6e1e6474 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -812,8 +812,8 @@ out_free:
/* Load smb.conf file */
- if (!lp_load(dyn_CONFIGFILE,True,False,False,True))
- fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
+ if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True))
+ fprintf(stderr, "Can't load %s\n", get_dyn_CONFIGFILE());
if ( strlen(new_workgroup) != 0 )
set_global_myworkgroup( new_workgroup );
diff --git a/source3/services/services_db.c b/source3/services/services_db.c
index 07f7aa6002..430c58f50d 100644
--- a/source3/services/services_db.c
+++ b/source3/services/services_db.c
@@ -197,7 +197,7 @@ static bool read_init_file( const char *servicename, struct rcinit_file_informat
/* attempt the file open */
- filepath = talloc_asprintf(info, "%s/%s/%s", dyn_LIBDIR,
+ filepath = talloc_asprintf(info, "%s/%s/%s", get_dyn_LIBDIR(),
SVCCTL_SCRIPT_DIR, servicename);
if (!filepath) {
TALLOC_FREE(info);
@@ -275,7 +275,7 @@ static void fill_service_values( const char *name, REGVAL_CTR *values )
if ( strequal( name, builtin_svcs[i].servicename ) ) {
char *pstr = NULL;
if (asprintf(&pstr, "%s/%s/%s",
- dyn_LIBDIR, SVCCTL_SCRIPT_DIR,
+ get_dyn_LIBDIR(), SVCCTL_SCRIPT_DIR,
builtin_svcs[i].daemon) > 0) {
init_unistr2( &ipath, pstr, UNI_STR_TERMINATE );
SAFE_FREE(pstr);
@@ -294,7 +294,7 @@ static void fill_service_values( const char *name, REGVAL_CTR *values )
char *pstr = NULL;
struct rcinit_file_information *init_info = NULL;
- if (asprintf(&pstr, "%s/%s/%s",dyn_LIBDIR,
+ if (asprintf(&pstr, "%s/%s/%s",get_dyn_LIBDIR(),
SVCCTL_SCRIPT_DIR, name) > 0) {
init_unistr2( &ipath, pstr, UNI_STR_TERMINATE );
SAFE_FREE(pstr);
diff --git a/source3/services/svc_rcinit.c b/source3/services/svc_rcinit.c
index 66f89f2248..b7684b951c 100644
--- a/source3/services/svc_rcinit.c
+++ b/source3/services/svc_rcinit.c
@@ -28,7 +28,7 @@ static WERROR rcinit_stop( const char *service, SERVICE_STATUS *status )
int ret, fd;
if (asprintf(&command, "%s/%s/%s stop",
- dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service) < 0) {
+ get_dyn_LIBDIR(), SVCCTL_SCRIPT_DIR, service) < 0) {
return WERR_NOMEM;
}
@@ -60,7 +60,7 @@ static WERROR rcinit_start( const char *service )
int ret, fd;
if (asprintf(&command, "%s/%s/%s start",
- dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service) < 0) {
+ get_dyn_LIBDIR(), SVCCTL_SCRIPT_DIR, service) < 0) {
return WERR_NOMEM;
}
@@ -87,7 +87,7 @@ static WERROR rcinit_status( const char *service, SERVICE_STATUS *status )
int ret, fd;
if (asprintf(&command, "%s/%s/%s status",
- dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service) < 0) {
+ get_dyn_LIBDIR(), SVCCTL_SCRIPT_DIR, service) < 0) {
return WERR_NOMEM;
}
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index feb5fa4b05..7df7de36dc 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -1972,7 +1972,7 @@ static bool api_RNetShareAdd(connection_struct *conn,uint16 vuid,
}
asprintf(&command, "%s \"%s\" \"%s\" \"%s\" \"%s\"",
- lp_add_share_cmd(), dyn_CONFIGFILE, sharename, pathname, comment);
+ lp_add_share_cmd(), get_dyn_CONFIGFILE(), sharename, pathname, comment);
if (command) {
DEBUG(10,("api_RNetShareAdd: Running [%s]\n", command ));
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 7d0dff0480..0aa8dac18d 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -738,8 +738,8 @@ bool reload_services(bool test)
if (lp_loaded()) {
char *fname = lp_configfile();
if (file_exist(fname, NULL) &&
- !strcsequal(fname, dyn_CONFIGFILE)) {
- strlcpy(dyn_CONFIGFILE, fname,sizeof(dyn_CONFIGFILE));
+ !strcsequal(fname, get_dyn_CONFIGFILE())) {
+ set_dyn_CONFIGFILE(fname);
test = False;
}
}
@@ -751,7 +751,7 @@ bool reload_services(bool test)
lp_killunused(conn_snum_used);
- ret = lp_load(dyn_CONFIGFILE, False, False, True, True);
+ ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
reload_printers();
diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
index 4dc8e53578..2ba5ab8f06 100644
--- a/source3/torture/locktest.c
+++ b/source3/torture/locktest.c
@@ -617,7 +617,7 @@ static void usage(void)
argc -= NSERVERS;
argv += NSERVERS;
- lp_load(dyn_CONFIGFILE,True,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
if (getenv("USER")) {
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index b99fdbc093..68e18439e8 100644
--- a/source3/torture/locktest2.c
+++ b/source3/torture/locktest2.c
@@ -505,7 +505,7 @@ static void usage(void)
argc -= 4;
argv += 4;
- lp_load(dyn_CONFIGFILE,True,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
if (getenv("USER")) {
diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c
index 3c037e727b..c5612fefaa 100644
--- a/source3/torture/masktest.c
+++ b/source3/torture/masktest.c
@@ -482,7 +482,7 @@ static void usage(void)
argc -= 1;
argv += 1;
- lp_load(dyn_CONFIGFILE,True,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
if (getenv("USER")) {
diff --git a/source3/torture/msgtest.c b/source3/torture/msgtest.c
index 3ef1d1e600..1bb616f6e1 100644
--- a/source3/torture/msgtest.c
+++ b/source3/torture/msgtest.c
@@ -49,7 +49,7 @@ static void pong_message(struct messaging_context *msg_ctx,
setup_logging(argv[0],True);
- lp_load(dyn_CONFIGFILE,False,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),False,False,False,True);
if (!(evt_ctx = event_context_init(NULL)) ||
!(msg_ctx = messaging_init(NULL, server_id_self(), evt_ctx))) {
diff --git a/source3/torture/pdbtest.c b/source3/torture/pdbtest.c
index a5b7075b4c..77666bb664 100644
--- a/source3/torture/pdbtest.c
+++ b/source3/torture/pdbtest.c
@@ -257,7 +257,7 @@ int main(int argc, char **argv)
poptFreeContext(pc);
/* Load configuration */
- lp_load(dyn_CONFIGFILE, False, False, True, True);
+ lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
setup_logging("pdbtest", True);
if (backend == NULL) {
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 1e6865b754..ad57470c61 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5309,7 +5309,7 @@ static void usage(void)
load_case_tables();
- lp_load(dyn_CONFIGFILE,True,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
if (argc < 2) {
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index 04bcfab3e7..1436ecc022 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -434,8 +434,8 @@ bool reload_services(bool test)
if (lp_loaded()) {
const char *fname = lp_configfile();
if (file_exist(fname, NULL) &&
- !strcsequal(fname, dyn_CONFIGFILE)) {
- strlcpy(dyn_CONFIGFILE, fname, sizeof(dyn_CONFIGFILE));
+ !strcsequal(fname, get_dyn_CONFIGFILE())) {
+ set_dyn_CONFIGFILE(fname);
test = False;
}
}
@@ -447,7 +447,7 @@ bool reload_services(bool test)
lp_killunused(conn_snum_used);
- ret = lp_load(dyn_CONFIGFILE, False, False, True, True);
+ ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
/* perhaps the config filename is now set */
if (!test)
diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c
index 424cee8189..c699f96be7 100644
--- a/source3/utils/eventlogadm.c
+++ b/source3/utils/eventlogadm.c
@@ -169,7 +169,7 @@ int main( int argc, char *argv[] )
opt_debug = 0; /* todo set this from getopts */
- lp_load( dyn_CONFIGFILE, True, False, False, True);
+ lp_load(get_dyn_CONFIGFILE(), True, False, False, True);
exename = argv[0];
diff --git a/source3/utils/net.c b/source3/utils/net.c
index e8fb2c4987..8118ec4512 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -1067,7 +1067,7 @@ static struct functable net_func[] = {
* set by cmdline arg or remain default (0)
*/
AllowDebugChange = False;
- lp_load(dyn_CONFIGFILE,True,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
argv_new = (const char **)poptGetArgs(pc);
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 37a02200f5..141031dacb 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -943,7 +943,7 @@ static NTSTATUS check_ads_config( void )
if ( lp_security() == SEC_ADS && !*lp_realm()) {
d_fprintf(stderr, "realm must be set in in %s for ADS "
- "join to succeed.\n", dyn_CONFIGFILE);
+ "join to succeed.\n", get_dyn_CONFIGFILE());
return NT_STATUS_INVALID_PARAMETER;
}
@@ -1494,7 +1494,7 @@ int net_ads_join(int argc, const char **argv)
if (strcmp(ads->config.realm, lp_realm()) != 0) {
d_fprintf(stderr, "realm of remote server (%s) and realm in %s "
"(%s) DO NOT match. Aborting join\n",
- ads->config.realm, dyn_CONFIGFILE, lp_realm());
+ ads->config.realm, get_dyn_CONFIGFILE(), lp_realm());
nt_status = NT_STATUS_INVALID_PARAMETER;
goto fail;
}
@@ -1571,11 +1571,11 @@ int net_ads_join(int argc, const char **argv)
/* Check the short name of the domain */
if ( !strequal(lp_workgroup(), short_domain_name) ) {
- d_printf("The workgroup in %s does not match the short\n", dyn_CONFIGFILE);
+ d_printf("The workgroup in %s does not match the short\n", get_dyn_CONFIGFILE());
d_printf("domain name obtained from the server.\n");
d_printf("Using the name [%s] from the server.\n", short_domain_name);
d_printf("You should set \"workgroup = %s\" in %s.\n",
- short_domain_name, dyn_CONFIGFILE);
+ short_domain_name, get_dyn_CONFIGFILE());
}
d_printf("Using short domain name -- %s\n", short_domain_name);
diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c
index dd2dddb7a8..c04b628b1b 100644
--- a/source3/utils/nmblookup.c
+++ b/source3/utils/nmblookup.c
@@ -314,9 +314,9 @@ int main(int argc,char *argv[])
exit(1);
}
- if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
+ if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
- dyn_CONFIGFILE);
+ get_dyn_CONFIGFILE());
}
load_interfaces();
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index 9312503d33..7e2771c900 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -2243,9 +2243,9 @@ enum {
/* Samba client initialisation */
- if (!lp_load(dyn_CONFIGFILE, True, False, False, True)) {
+ if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, True)) {
d_fprintf(stderr, "ntlm_auth: error opening config file %s. Error was %s\n",
- dyn_CONFIGFILE, strerror(errno));
+ get_dyn_CONFIGFILE(), strerror(errno));
exit(1);
}
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index c72d98953d..7d23c67f0c 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -828,8 +828,8 @@ int main (int argc, char **argv)
if (user_name == NULL)
user_name = poptGetArg(pc);
- if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
- fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
+ if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True)) {
+ fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE());
exit(1);
}
diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c
index cd2c78f8f3..3da406dd34 100644
--- a/source3/utils/sharesec.c
+++ b/source3/utils/sharesec.c
@@ -573,7 +573,7 @@ int main(int argc, const char *argv[])
load_case_tables();
- lp_load( dyn_CONFIGFILE, False, False, False, True );
+ lp_load( get_dyn_CONFIGFILE(), False, False, False, True );
/* check for initializing secrets.tdb first */
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index e5ba8e5d0b..f823ea3bfd 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -895,7 +895,7 @@ static struct cli_state *connect_one(const char *server, const char *share)
setlinebuf(stdout);
- lp_load(dyn_CONFIGFILE,True,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
pc = poptGetContext("smbcacls", argc, argv, long_options, 0);
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 835adca4bd..fe0c22911e 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -1340,7 +1340,7 @@ int main(int argc, const char **argv)
if (argc <= 1)
usage(pc);
- lp_load(dyn_CONFIGFILE,False,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),False,False,False,True);
/* Need to invert sense of return code -- samba
* routines mostly return True==1 for success, but
diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c
index 34a547d404..08a3cc1806 100644
--- a/source3/utils/smbcquotas.c
+++ b/source3/utils/smbcquotas.c
@@ -448,7 +448,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" },
fault_setup(NULL);
- lp_load(dyn_CONFIGFILE,True,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
pc = poptGetContext("smbcquotas", argc, argv, long_options, 0);
diff --git a/source3/utils/smbfilter.c b/source3/utils/smbfilter.c
index 89a38d5b40..912d575c60 100644
--- a/source3/utils/smbfilter.c
+++ b/source3/utils/smbfilter.c
@@ -235,7 +235,7 @@ int main(int argc, char *argv[])
setup_logging(argv[0],True);
- configfile = dyn_CONFIGFILE;
+ configfile = get_dyn_CONFIGFILE();
if (argc < 2) {
fprintf(stderr,"smbfilter <desthost> <netbiosname>\n");
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index fc5933cc1a..ea3bb38dc4 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -83,7 +83,7 @@ static void set_line_buffering(FILE *f)
static int process_options(int argc, char **argv, int local_flags)
{
int ch;
- const char *configfile = dyn_CONFIGFILE;
+ const char *configfile = get_dyn_CONFIGFILE();
local_flags |= LOCAL_SET_PASSWORD;
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index cf880498c1..572f3dca83 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -291,7 +291,7 @@ static bool print_tree(struct user_auth_info *user_info)
while(poptGetNextOpt(pc) != -1);
poptFreeContext(pc);
- lp_load(dyn_CONFIGFILE,True,False,False,True);
+ lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
load_interfaces();
/* Parse command line args */
diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c
index ba78eb22fc..eface2fc46 100644
--- a/source3/utils/smbw_sample.c
+++ b/source3/utils/smbw_sample.c
@@ -32,8 +32,9 @@ int main(int argc, char *argv[])
extern char *optarg;
extern int optind;
char *path;
+ TALLOC_CTX *frame = talloc_stackframe();
- lp_load(dyn_CONFIGFILE,1,0,0,1);
+ lp_load(get_dyn_CONFIGFILE(),1,0,0,1);
smbw_setup_shared();
while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) {
@@ -90,5 +91,6 @@ int main(int argc, char *argv[])
printf("%s\n", dent->d_name);
}
smbw_closedir(dir);
+ TALLOC_FREE(frame);
return 0;
}
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 5de80fa555..a42c2a11e0 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -356,11 +356,11 @@ static int traverse_sessionid(struct db_record *db, void *state)
Ucrit_addUid( nametouid(username) );
if (verbose) {
- d_printf("using configfile = %s\n", dyn_CONFIGFILE);
+ d_printf("using configfile = %s\n", get_dyn_CONFIGFILE());
}
- if (!lp_load(dyn_CONFIGFILE,False,False,False,True)) {
- fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
+ if (!lp_load(get_dyn_CONFIGFILE(),False,False,False,True)) {
+ fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE());
ret = -1;
goto done;
}
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index aa519565ad..fbfc85535c 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -199,7 +199,7 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_
int main(int argc, const char *argv[])
{
- const char *config_file = dyn_CONFIGFILE;
+ const char *config_file = get_dyn_CONFIGFILE();
int s;
static int silent_mode = False;
static int show_all_parameters = False;
diff --git a/source3/web/startstop.c b/source3/web/startstop.c
index 436666f849..b24410a89f 100644
--- a/source3/web/startstop.c
+++ b/source3/web/startstop.c
@@ -35,7 +35,7 @@ void start_smbd(void)
return;
}
- if (asprintf(&binfile, "%s/smbd", dyn_SBINDIR) > 0) {
+ if (asprintf(&binfile, "%s/smbd", get_dyn_SBINDIR()) > 0) {
become_daemon(true, false);
execl(binfile, binfile, "-D", NULL);
}
@@ -55,7 +55,7 @@ void start_nmbd(void)
return;
}
- if (asprintf(&binfile, "%s/nmbd", dyn_SBINDIR) > 0) {
+ if (asprintf(&binfile, "%s/nmbd", get_dyn_SBINDIR()) > 0) {
become_daemon(true, false);
execl(binfile, binfile, "-D", NULL);
}
@@ -75,7 +75,7 @@ void start_winbindd(void)
return;
}
- if (asprintf(&binfile, "%s/winbindd", dyn_SBINDIR) > 0) {
+ if (asprintf(&binfile, "%s/winbindd", get_dyn_SBINDIR()) > 0) {
become_daemon(true, false);
execl(binfile, binfile, NULL);
}
diff --git a/source3/web/swat.c b/source3/web/swat.c
index 3440010f43..2cf0eabeed 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -430,7 +430,7 @@ static void show_parameters(int snum, int allparameters, unsigned int parm_filte
static bool load_config(bool save_def)
{
lp_resetnumservices();
- return lp_load(dyn_CONFIGFILE,False,save_def,False,True);
+ return lp_load(get_dyn_CONFIGFILE(),False,save_def,False,True);
}
/****************************************************************************
@@ -453,9 +453,9 @@ static int save_reload(int snum)
FILE *f;
struct stat st;
- f = sys_fopen(dyn_CONFIGFILE,"w");
+ f = sys_fopen(get_dyn_CONFIGFILE(),"w");
if (!f) {
- printf(_("failed to open %s for writing"), dyn_CONFIGFILE);
+ printf(_("failed to open %s for writing"), get_dyn_CONFIGFILE());
printf("\n");
return 0;
}
@@ -466,7 +466,7 @@ static int save_reload(int snum)
#if defined HAVE_FCHMOD
fchmod(fileno(f), S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
#else
- chmod(dyn_CONFIGFILE, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
+ chmod(get_dyn_CONFIGFILE(), S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
#endif
}
@@ -478,7 +478,7 @@ static int save_reload(int snum)
lp_killunused(NULL);
if (!load_config(False)) {
- printf(_("Can't reload %s"), dyn_CONFIGFILE);
+ printf(_("Can't reload %s"), get_dyn_CONFIGFILE());
printf("\n");
return 0;
}
@@ -1422,23 +1422,23 @@ const char *lang_msg_rotate(TALLOC_CTX *ctx, const char *msgid)
iNumNonAutoPrintServices = lp_numservices();
load_printers();
- cgi_setup(dyn_SWATDIR, !demo_mode);
+ cgi_setup(get_dyn_SWATDIR(), !demo_mode);
print_header();
cgi_load_variables();
- if (!file_exist(dyn_CONFIGFILE, NULL)) {
+ if (!file_exist(get_dyn_CONFIGFILE(), NULL)) {
have_read_access = True;
have_write_access = True;
} else {
/* check if the authenticated user has write access - if not then
don't show write options */
- have_write_access = (access(dyn_CONFIGFILE,W_OK) == 0);
+ have_write_access = (access(get_dyn_CONFIGFILE(),W_OK) == 0);
/* if the user doesn't have read access to smb.conf then
don't let them view it */
- have_read_access = (access(dyn_CONFIGFILE,R_OK) == 0);
+ have_read_access = (access(get_dyn_CONFIGFILE(),R_OK) == 0);
}
show_main_buttons();
diff --git a/source3/winbindd/idmap.c b/source3/winbindd/idmap.c
index d2c13ab8b7..af8ec17b4e 100644
--- a/source3/winbindd/idmap.c
+++ b/source3/winbindd/idmap.c
@@ -333,7 +333,7 @@ NTSTATUS idmap_init(void)
DEBUG(0, ("WARNING: idmap backend uses obsolete"
" and deprecated 'idmap_' prefix.\n"
"Please replace 'idmap_%s' by '%s' in"
- " %s\n", q, q, dyn_CONFIGFILE));
+ " %s\n", q, q, get_dyn_CONFIGFILE()));
compat_backend = talloc_strdup(idmap_ctx, q);
} else {
compat_backend = talloc_strdup(idmap_ctx,
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 53571d6002..598ec8e428 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -63,13 +63,13 @@ static bool reload_services_file(void)
if (lp_loaded()) {
const char *fname = lp_configfile();
- if (file_exist(fname,NULL) && !strcsequal(fname,dyn_CONFIGFILE)) {
- strlcpy(dyn_CONFIGFILE,fname,sizeof(dyn_CONFIGFILE));
+ if (file_exist(fname,NULL) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
+ set_dyn_CONFIGFILE(fname);
}
}
reopen_logs();
- ret = lp_load(dyn_CONFIGFILE,False,False,True,True);
+ ret = lp_load(get_dyn_CONFIGFILE(),False,False,True,True);
reopen_logs();
load_interfaces();
@@ -1088,7 +1088,7 @@ int main(int argc, char **argv, char **envp)
if (!override_logfile) {
char *logfile = NULL;
if (asprintf(&logfile,"%s/log.winbindd",
- dyn_LOGFILEBASE) > 0) {
+ get_dyn_LOGFILEBASE()) > 0) {
lp_set_logfile(logfile);
SAFE_FREE(logfile);
}
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index b64937da23..3f6544965d 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -209,7 +209,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
if (!override_logfile) {
char *logfile;
- if (asprintf(&logfile, "%s/log.winbindd-dc-connect", dyn_LOGFILEBASE) > 0) {
+ if (asprintf(&logfile, "%s/log.winbindd-dc-connect", get_dyn_LOGFILEBASE()) > 0) {
lp_set_logfile(logfile);
SAFE_FREE(logfile);
reopen_logs();
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 91e60cca36..1e76c12d4b 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -472,12 +472,12 @@ void setup_domain_child(struct winbindd_domain *domain,
{
if (explicit_logfile != NULL) {
if (asprintf(&child->logfilename, "%s/log.winbindd-%s",
- dyn_LOGFILEBASE, explicit_logfile) < 0) {
+ get_dyn_LOGFILEBASE(), explicit_logfile) < 0) {
smb_panic("Internal error: asprintf failed");
}
} else if (domain != NULL) {
if (asprintf(&child->logfilename, "%s/log.wb-%s",
- dyn_LOGFILEBASE, domain->name) < 0) {
+ get_dyn_LOGFILEBASE(), domain->name) < 0) {
smb_panic("Internal error: asprintf failed");
}
} else {