summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2008-02-04 16:16:59 +0100
committerKai Blin <kai@samba.org>2008-02-04 17:41:23 +0100
commit174100c30997e6ae70492528da998e30c1bfce60 (patch)
tree3683845c1fb615aca269b528ef87f86cbd9ebe92
parent555941383348f0f740ac169da7b3325f225e9261 (diff)
downloadsamba-174100c30997e6ae70492528da998e30c1bfce60.tar.gz
samba-174100c30997e6ae70492528da998e30c1bfce60.tar.bz2
samba-174100c30997e6ae70492528da998e30c1bfce60.zip
popt: Use SMB_CONF_PATH environment var if no other configfile is set.
Now --configfile (or -s) will have precedence, if that's not given SMB_CONF_PATH is checked, otherwise the $(CONFIGDIR)/smb.conf default value is used. Thanks to Michael for his comments. (This used to be commit 92a9c6c56fa90aead3b7f4a07bf4f3973ba23555)
-rw-r--r--source3/dynconfig.c5
-rw-r--r--source3/include/dynconfig.h16
-rw-r--r--source3/lib/popt_common.c15
3 files changed, 33 insertions, 3 deletions
diff --git a/source3/dynconfig.c b/source3/dynconfig.c
index ab0dd48da7..57008ece44 100644
--- a/source3/dynconfig.c
+++ b/source3/dynconfig.c
@@ -64,6 +64,11 @@ static char *dyn_##name; \
}\
dyn_##name = SMB_STRDUP(newpath);\
return dyn_##name;\
+}\
+\
+ bool is_default_dyn_##name(void) \
+{\
+ return (dyn_##name == NULL);\
}
DEFINE_DYN_CONFIG_PARAM(SBINDIR)
diff --git a/source3/include/dynconfig.h b/source3/include/dynconfig.h
index bb7e2c20f4..cba71645bd 100644
--- a/source3/include/dynconfig.h
+++ b/source3/include/dynconfig.h
@@ -41,42 +41,58 @@ extern char dyn_PRIVATE_DIR[1024];
const char *get_dyn_SBINDIR(void);
const char *set_dyn_SBINDIR(const char *newpath);
+bool is_default_dyn_SBINDIR(void);
const char *get_dyn_BINDIR(void);
const char *set_dyn_BINDIR(const char *newpath);
+bool is_default_dyn_BINDIR(void);
const char *get_dyn_SWATDIR(void);
const char *set_dyn_SWATDIR(const char *newpath);
+bool is_default_dyn_SWATDIR(void);
const char *get_dyn_CONFIGFILE(void);
const char *set_dyn_CONFIGFILE(const char *newpath);
+bool is_default_dyn_CONFIGFILE(void);
const char *get_dyn_dyn_LOGFILEBASE(void);
const char *set_dyn_dyn_LOGFILEBASE(const char *newpath);
+bool is_default_dyn_LOGFILEBASE(void);
const char *get_dyn_LMHOSTSFILE(void);
const char *set_dyn_LMHOSTSFILE(const char *newpath);
+bool is_default_dyn_LOGFILEBASE(void);
const char *get_dyn_CODEPAGEDIR(void);
const char *set_dyn_CODEPAGEDIR(const char *newpath);
+bool is_default_dyn_CODEPAGEDIR(void);
const char *get_dyn_LIBDIR(void);
const char *set_dyn_LIBDIR(const char *newpath);
+bool is_default_dyn_LIBDIR(void);
const char *get_dyn_SHLIBEXT(void);
const char *set_dyn_SHLIBEXT(const char *newpath);
+bool is_default_dyn_SHLIBEXT(void);
const char *get_dyn_LOCKDIR(void);
const char *set_dyn_LOCKDIR(const char *newpath);
+bool is_default_dyn_LOCKDIR(void);
const char *get_dyn_PIDDIR(void);
const char *set_dyn_PIDDIR(const char *newpath);
+bool is_default_dyn_PIDDIR(void);
const char *get_dyn_SMB_PASSWD_FILE(void);
const char *set_dyn_SMB_PASSWD_FILE(const char *newpath);
+bool is_default_dyn_SMB_PASSWD_FILE(void);
const char *get_dyn_PRIVATE_DIR(void);
const char *set_dyn_PRIVATE_DIR(const char *newpath);
+bool is_default_dyn_PRIVATE_DIR(void);
const char *get_dyn_STATEDIR(void);
+bool is_default_dyn_STATEDIR(void);
+
const char *get_dyn_CACHEDIR(void);
+bool is_default_dyn_CACHEDIR(bool);
diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index 5a9d39d181..7f7d23fa00 100644
--- a/source3/lib/popt_common.c
+++ b/source3/lib/popt_common.c
@@ -71,10 +71,19 @@ static void popt_common_callback(poptContext con,
}
if (reason == POPT_CALLBACK_REASON_POST) {
- if (!PrintSambaVersionString) return;
- printf( "Version %s\n", SAMBA_VERSION_STRING);
- exit(0);
+ if (PrintSambaVersionString) {
+ printf( "Version %s\n", SAMBA_VERSION_STRING);
+ exit(0);
+ }
+
+ if (is_default_dyn_CONFIGFILE()) {
+ if(getenv("SMB_CONF_PATH")) {
+ set_dyn_CONFIGFILE(getenv("SMB_CONF_PATH"));
+ }
+ }
+
+ /* Further 'every Samba program must do this' hooks here. */
return;
}