summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/dynconfig.c10
-rw-r--r--source3/include/dynconfig.h10
-rw-r--r--source3/include/popt_common.h4
-rw-r--r--source3/lib/popt_common.c154
-rw-r--r--source3/smbd/server.c9
5 files changed, 162 insertions, 25 deletions
diff --git a/source3/dynconfig.c b/source3/dynconfig.c
index 34c716926c..3104a12f7c 100644
--- a/source3/dynconfig.c
+++ b/source3/dynconfig.c
@@ -58,15 +58,15 @@ pstring dyn_LMHOSTSFILE = LMHOSTSFILE;
* @sa lib_path() to get the path to a file inside the LIBDIR.
**/
pstring dyn_LIBDIR = LIBDIR;
-const fstring dyn_SHLIBEXT = SHLIBEXT;
+fstring dyn_SHLIBEXT = SHLIBEXT;
/**
* @brief Directory holding lock files.
*
* Not writable, but used to set a default in the parameter table.
**/
-const pstring dyn_LOCKDIR = LOCKDIR;
-const pstring dyn_PIDDIR = PIDDIR;
+pstring dyn_LOCKDIR = LOCKDIR;
+pstring dyn_PIDDIR = PIDDIR;
-const pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE;
-const pstring dyn_PRIVATE_DIR = PRIVATE_DIR;
+pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE;
+pstring dyn_PRIVATE_DIR = PRIVATE_DIR;
diff --git a/source3/include/dynconfig.h b/source3/include/dynconfig.h
index a74d77e41f..aebc9c941e 100644
--- a/source3/include/dynconfig.h
+++ b/source3/include/dynconfig.h
@@ -31,8 +31,8 @@ extern char const *dyn_SBINDIR,
extern pstring dyn_CONFIGFILE;
extern pstring dyn_LOGFILEBASE, dyn_LMHOSTSFILE;
extern pstring dyn_LIBDIR;
-extern const fstring dyn_SHLIBEXT;
-extern const pstring dyn_LOCKDIR;
-extern const pstring dyn_PIDDIR;
-extern const pstring dyn_SMB_PASSWD_FILE;
-extern const pstring dyn_PRIVATE_DIR;
+extern fstring dyn_SHLIBEXT;
+extern pstring dyn_LOCKDIR;
+extern pstring dyn_PIDDIR;
+extern pstring dyn_SMB_PASSWD_FILE;
+extern pstring dyn_PRIVATE_DIR;
diff --git a/source3/include/popt_common.h b/source3/include/popt_common.h
index 7c0a86836d..4c3facb48f 100644
--- a/source3/include/popt_common.h
+++ b/source3/include/popt_common.h
@@ -28,6 +28,7 @@ extern struct poptOption popt_common_samba[];
extern struct poptOption popt_common_connection[];
extern struct poptOption popt_common_version[];
extern struct poptOption popt_common_credentials[];
+extern const struct poptOption popt_common_dynconfig[];
#ifndef POPT_TABLEEND
#define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
@@ -37,6 +38,9 @@ extern struct poptOption popt_common_credentials[];
#define POPT_COMMON_CONNECTION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_connection, 0, "Connection options:", NULL },
#define POPT_COMMON_VERSION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version, 0, "Common samba options:", NULL },
#define POPT_COMMON_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL },
+#define POPT_COMMON_DYNCONFIG { NULL, 0, POPT_ARG_INCLUDE_TABLE, \
+ CONST_DISCARD(poptOption *, popt_common_dynconfig), 0, \
+ "Build-time configuration overrides:", NULL },
struct user_auth_info {
pstring username;
diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index 6c35213d43..f842ae8011 100644
--- a/source3/lib/popt_common.c
+++ b/source3/lib/popt_common.c
@@ -4,6 +4,7 @@
Copyright (C) Tim Potter 2001,2002
Copyright (C) Jelmer Vernooij 2002,2003
+ Copyright (C) James Peach 2006
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
@@ -39,11 +40,9 @@ extern BOOL override_logfile;
struct user_auth_info cmdline_auth_info;
-static void popt_common_callback(poptContext con,
- enum poptCallbackReason reason,
- const struct poptOption *opt,
- const char *arg, const void *data)
+static void set_logfile(poptContext con, const char * arg)
{
+
pstring logfile;
const char *pname;
@@ -55,9 +54,19 @@ static void popt_common_callback(poptContext con,
else
pname++;
+ pstr_sprintf(logfile, "%s/log.%s", arg, pname);
+ lp_set_logfile(logfile);
+ override_logfile = True;
+}
+
+static void popt_common_callback(poptContext con,
+ enum poptCallbackReason reason,
+ const struct poptOption *opt,
+ const char *arg, const void *data)
+{
+
if (reason == POPT_CALLBACK_REASON_PRE) {
- pstr_sprintf(logfile, "%s/log.%s", dyn_LOGFILEBASE, pname);
- lp_set_logfile(logfile);
+ set_logfile(con, dyn_LOGFILEBASE);
return;
}
@@ -94,9 +103,8 @@ static void popt_common_callback(poptContext con,
case 'l':
if (arg) {
- pstr_sprintf(logfile, "%s/log.%s", arg, pname);
- lp_set_logfile(logfile);
- override_logfile = True;
+ set_logfile(con, arg);
+ pstr_sprintf(dyn_LOGFILEBASE, "%s", arg);
}
break;
@@ -128,8 +136,8 @@ struct poptOption popt_common_connection[] = {
struct poptOption popt_common_samba[] = {
{ NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback },
{ "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" },
- { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" },
- { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" },
+ { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternate configuration file", "CONFIGFILE" },
+ { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Base name for log files", "LOGFILEBASE" },
{ "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" },
POPT_TABLEEND
};
@@ -141,6 +149,130 @@ struct poptOption popt_common_version[] = {
};
+/* Handle command line options:
+ * --sbindir
+ * --bindir
+ * --swatdir
+ * --lmhostsfile
+ * --libdir
+ * --shlibext
+ * --lockdir
+ * --piddir
+ * --smb-passwd-file
+ * --private-dir
+ */
+
+enum dyn_item{
+ DYN_SBINDIR = 1,
+ DYN_BINDIR,
+ DYN_SWATDIR,
+ DYN_LMHOSTSFILE,
+ DYN_LIBDIR,
+ DYN_SHLIBEXT,
+ DYN_LOCKDIR,
+ DYN_PIDDIR,
+ DYN_SMB_PASSWD_FILE,
+ DYN_PRIVATE_DIR,
+};
+
+
+static void popt_dynconfig_callback(poptContext con,
+ enum poptCallbackReason reason,
+ const struct poptOption *opt,
+ const char *arg, const void *data)
+{
+
+ switch (opt->val) {
+ case DYN_SBINDIR:
+ if (arg) {
+ dyn_SBINDIR = SMB_STRDUP(arg);
+ }
+ break;
+
+ case DYN_BINDIR:
+ if (arg) {
+ dyn_BINDIR = SMB_STRDUP(arg);
+ }
+ break;
+
+ case DYN_SWATDIR:
+ if (arg) {
+ dyn_SWATDIR = SMB_STRDUP(arg);
+ }
+ break;
+
+ case DYN_LMHOSTSFILE:
+ if (arg) {
+ pstrcpy(dyn_LMHOSTSFILE, arg);
+ }
+ break;
+
+ case DYN_LIBDIR:
+ if (arg) {
+ pstrcpy(dyn_LIBDIR, arg);
+ }
+ break;
+
+ case DYN_SHLIBEXT:
+ if (arg) {
+ fstrcpy(dyn_SHLIBEXT, arg);
+ }
+ break;
+
+ case DYN_LOCKDIR:
+ if (arg) {
+ pstrcpy(dyn_LOCKDIR, arg);
+ }
+ break;
+
+ case DYN_PIDDIR:
+ if (arg) {
+ pstrcpy(dyn_PIDDIR, arg);
+ }
+ break;
+
+ case DYN_SMB_PASSWD_FILE:
+ if (arg) {
+ pstrcpy(dyn_SMB_PASSWD_FILE, arg);
+ }
+ break;
+
+ case DYN_PRIVATE_DIR:
+ if (arg) {
+ pstrcpy(dyn_PRIVATE_DIR, arg);
+ }
+ break;
+
+ }
+}
+
+const struct poptOption popt_common_dynconfig[] = {
+
+ { NULL, '\0', POPT_ARG_CALLBACK, popt_dynconfig_callback },
+
+ { "sbindir", '\0' , POPT_ARG_STRING, NULL, DYN_SBINDIR,
+ "Path to sbin directory", "SBINDIR" },
+ { "bindir", '\0' , POPT_ARG_STRING, NULL, DYN_BINDIR,
+ "Path to bin directory", "BINDIR" },
+ { "swatdir", '\0' , POPT_ARG_STRING, NULL, DYN_SWATDIR,
+ "Path to SWAT installation directory", "SWATDIR" },
+ { "lmhostsfile", '\0' , POPT_ARG_STRING, NULL, DYN_LMHOSTSFILE,
+ "Path to lmhosts file", "LMHOSTSFILE" },
+ { "libdir", '\0' , POPT_ARG_STRING, NULL, DYN_LIBDIR,
+ "Path to shared library directory", "LIBDIR" },
+ { "shlibext", '\0' , POPT_ARG_STRING, NULL, DYN_SHLIBEXT,
+ "Shared library extension", "SHLIBEXT" },
+ { "lockdir", '\0' , POPT_ARG_STRING, NULL, DYN_LOCKDIR,
+ "Path to lock file directory", "LOCKDIR" },
+ { "piddir", '\0' , POPT_ARG_STRING, NULL, DYN_PIDDIR,
+ "Path to PID file directory", "PIDDIR" },
+ { "smb-passwd-file", '\0' , POPT_ARG_STRING, NULL, DYN_SMB_PASSWD_FILE,
+ "Path to smbpasswd file", "SMB_PASSWD_FILE" },
+ { "private-dir", '\0' , POPT_ARG_STRING, NULL, DYN_PRIVATE_DIR,
+ "Path to private data directory", "PRIVATE_DIR" },
+
+ POPT_TABLEEND
+};
/****************************************************************************
* get a password from a a file or file descriptor
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index d16579f24a..2bfeae9f54 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -744,16 +744,17 @@ void build_options(BOOL screen);
poptContext pc;
struct poptOption long_options[] = {
- POPT_AUTOHELP
+ POPT_AUTOHELP
{"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon (default)" },
{"interactive", 'i', POPT_ARG_VAL, &interactive, True, "Run interactive (not a daemon)"},
- {"foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools & etc)" },
- {"no-process-group", 0, POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
+ {"foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools, etc.)" },
+ {"no-process-group", '\0', POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
{"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
{"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" },
{"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"},
POPT_COMMON_SAMBA
- { NULL }
+ POPT_COMMON_DYNCONFIG
+ POPT_TABLEEND
};
load_case_tables();