1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00

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 commit is contained in:
Andrew Tridgell 2004-09-13 01:27:37 +00:00 committed by Gerald (Jerry) Carter
parent daaee86d14
commit 360a6b530e
2 changed files with 42 additions and 3 deletions

View File

@ -33,6 +33,9 @@
* -i,--scope * -i,--scope
*/ */
enum {OPT_OPTION=1};
static struct cmdline_auth_info cmdline_auth_info; static struct cmdline_auth_info cmdline_auth_info;
static void popt_common_callback(poptContext con, static void popt_common_callback(poptContext con,
@ -40,7 +43,6 @@ static void popt_common_callback(poptContext con,
const struct poptOption *opt, const struct poptOption *opt,
const char *arg, const void *data) const char *arg, const void *data)
{ {
pstring logfile;
const char *pname; const char *pname;
/* Find out basename of current program */ /* Find out basename of current program */
@ -52,8 +54,9 @@ static void popt_common_callback(poptContext con,
pname++; pname++;
if (reason == POPT_CALLBACK_REASON_PRE) { 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); lp_set_cmdline("log file", logfile);
talloc_free(logfile);
return; return;
} }
@ -81,8 +84,9 @@ static void popt_common_callback(poptContext con,
case 'l': case 'l':
if (arg) { 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); lp_set_cmdline("log file", logfile);
talloc_free(logfile);
} }
break; break;
@ -105,6 +109,13 @@ static void popt_common_callback(poptContext con,
case 'R': case 'R':
lp_set_cmdline("name resolve order", arg); lp_set_cmdline("name resolve order", arg);
break; 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 }, { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback },
{ "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" },
{ "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, { "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" }, { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" },
POPT_TABLEEND POPT_TABLEEND
}; };

View File

@ -2639,6 +2639,33 @@ BOOL lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
return True; return True;
} }
/*
set a option from the commandline in 'a=b' format. Use to support --option
*/
BOOL lp_set_option(const char *option)
{
char *p, *s;
BOOL ret;
s = strdup(option);
if (!s) {
return False;
}
p = strchr(s, '=');
if (!p) {
free(s);
return False;
}
*p = 0;
ret = lp_set_cmdline(s, p+1);
free(s);
return ret;
}
/*************************************************************************** /***************************************************************************
Print a parameter of the specified type. Print a parameter of the specified type.
***************************************************************************/ ***************************************************************************/