diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-09-13 01:27:37 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:41 -0500 |
commit | 871604e3101edfd4c17eec5b05077eeb5674b26b (patch) | |
tree | cffd9bcccf2dd2047d44af848d57d1f7452a4f5c /source4/lib/cmdline | |
parent | 2d5ca36872d10138ac997a0d91916abb9b637c6e (diff) | |
download | samba-871604e3101edfd4c17eec5b05077eeb5674b26b.tar.gz samba-871604e3101edfd4c17eec5b05077eeb5674b26b.tar.bz2 samba-871604e3101edfd4c17eec5b05077eeb5674b26b.zip |
r2302: added a '--option' option, allowing any global or default option in
smb.conf to be set on the command line. For example, you can use:
smbtorture --option 'unicode=false'
or
smbtorture --option 'netbios name=myname'
(This used to be commit 360a6b530e2295976ddefc138d1333411a94484d)
Diffstat (limited to 'source4/lib/cmdline')
-rw-r--r-- | source4/lib/cmdline/popt_common.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 51018facb8..e2deb5db96 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -33,6 +33,9 @@ * -i,--scope */ + +enum {OPT_OPTION=1}; + static struct cmdline_auth_info cmdline_auth_info; static void popt_common_callback(poptContext con, @@ -40,7 +43,6 @@ static void popt_common_callback(poptContext con, const struct poptOption *opt, const char *arg, const void *data) { - pstring logfile; const char *pname; /* Find out basename of current program */ @@ -52,8 +54,9 @@ static void popt_common_callback(poptContext con, pname++; if (reason == POPT_CALLBACK_REASON_PRE) { - pstr_sprintf(logfile, "%s/log.%s", dyn_LOGFILEBASE, pname); + char *logfile = talloc_asprintf(NULL, "%s/log.%s", dyn_LOGFILEBASE, pname); lp_set_cmdline("log file", logfile); + talloc_free(logfile); return; } @@ -81,8 +84,9 @@ static void popt_common_callback(poptContext con, case 'l': if (arg) { - pstr_sprintf(logfile, "%s/log.%s", arg, pname); + char *logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname); lp_set_cmdline("log file", logfile); + talloc_free(logfile); } break; @@ -105,6 +109,13 @@ static void popt_common_callback(poptContext con, case 'R': lp_set_cmdline("name resolve order", arg); break; + + case OPT_OPTION: + if (!lp_set_option(arg)) { + fprintf(stderr, "Error setting option '%s'\n", arg); + exit(1); + } + break; } } @@ -123,6 +134,7 @@ 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" }, + { "option", 0, POPT_ARG_STRING, NULL, OPT_OPTION, "Set smb.conf option from command line", "name=value" }, { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, POPT_TABLEEND }; |