1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

r25392: Add loadparm context as argument in a couple more places.

(This used to be commit c62f51cc28)
This commit is contained in:
Jelmer Vernooij 2007-09-27 23:31:28 +00:00 committed by Gerald (Jerry) Carter
parent 3ff257b36b
commit 3048e9ad65
21 changed files with 88 additions and 83 deletions

View File

@ -395,7 +395,7 @@ static void set_max_xmit(uint64_t iomax)
char buf[64];
snprintf(buf, sizeof(buf), "%llu", (unsigned long long)iomax);
lp_set_cmdline("max xmit", buf);
lp_set_cmdline(global_loadparm, "max xmit", buf);
}
static int copy_files(void)

View File

@ -119,7 +119,7 @@ static smb_iconv_t get_conv_handle(charset_t from, charset_t to)
strcasecmp(charset_name(CH_DOS), "ASCII") != 0) {
DEBUG(0,("dos charset '%s' unavailable - using ASCII\n",
charset_name(CH_DOS)));
lp_set_cmdline("dos charset", "ASCII");
lp_set_cmdline(global_loadparm, "dos charset", "ASCII");
n1 = charset_name(from);
n2 = charset_name(to);

View File

@ -78,14 +78,14 @@ static void popt_common_callback(poptContext con,
setup_logging(pname, DEBUG_STDOUT);
if (getenv("SMB_CONF_PATH")) {
lp_set_cmdline("config file", getenv("SMB_CONF_PATH"));
lp_set_cmdline(global_loadparm, "config file", getenv("SMB_CONF_PATH"));
}
return;
}
switch(opt->val) {
case 'd':
lp_set_cmdline("log level", arg);
lp_set_cmdline(global_loadparm, "log level", arg);
break;
case OPT_DEBUG_STDERR:
@ -98,50 +98,50 @@ static void popt_common_callback(poptContext con,
case 'O':
if (arg) {
lp_set_cmdline("socket options", arg);
lp_set_cmdline(global_loadparm, "socket options", arg);
}
break;
case 's':
if (arg) {
lp_set_cmdline("config file", arg);
lp_set_cmdline(global_loadparm, "config file", arg);
}
break;
case 'l':
if (arg) {
char *new_logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname);
lp_set_cmdline("log file", new_logfile);
lp_set_cmdline(global_loadparm, "log file", new_logfile);
talloc_free(new_logfile);
}
break;
case 'W':
lp_set_cmdline("workgroup", arg);
lp_set_cmdline(global_loadparm, "workgroup", arg);
break;
case 'r':
lp_set_cmdline("realm", arg);
lp_set_cmdline(global_loadparm, "realm", arg);
break;
case 'n':
lp_set_cmdline("netbios name", arg);
lp_set_cmdline(global_loadparm, "netbios name", arg);
break;
case 'i':
lp_set_cmdline("netbios scope", arg);
lp_set_cmdline(global_loadparm, "netbios scope", arg);
break;
case 'm':
lp_set_cmdline("client max protocol", arg);
lp_set_cmdline(global_loadparm, "client max protocol", arg);
break;
case 'R':
lp_set_cmdline("name resolve order", arg);
lp_set_cmdline(global_loadparm, "name resolve order", arg);
break;
case OPT_OPTION:
if (!lp_set_option(arg)) {
if (!lp_set_option(global_loadparm, arg)) {
fprintf(stderr, "Error setting option '%s'\n", arg);
exit(1);
}

View File

@ -95,7 +95,7 @@ static void popt_common_credentials_callback(poptContext con,
break;
case 'S':
lp_set_cmdline("client signing", arg);
lp_set_cmdline(global_loadparm, "client signing", arg);
break;
case 'P':

View File

@ -1182,7 +1182,7 @@ static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
string_set(service, &service->szPath, tmpdir());
service->comment = talloc_asprintf(service, "%s Service (%s)",
fstype, loadparm.Globals.szServerString);
fstype, lp_ctx->Globals.szServerString);
string_set(service, &service->fstype, fstype);
service->iMaxConnections = -1;
service->bAvailable = true;
@ -1861,7 +1861,8 @@ bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
parsing code. It sets the parameter then marks the parameter as unable to be modified
by smb.conf processing
*/
bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
const char *pszParmValue)
{
int parmnum = map_parameter(pszParmName);
int i;
@ -1882,7 +1883,7 @@ bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
/* reset the CMDLINE flag in case this has been called before */
parm_table[parmnum].flags &= ~FLAG_CMDLINE;
if (!lp_do_global_parameter(&loadparm, pszParmName, pszParmValue)) {
if (!lp_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
return false;
}
@ -1902,7 +1903,7 @@ bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
/*
set a option from the commandline in 'a=b' format. Use to support --option
*/
bool lp_set_option(const char *option)
bool lp_set_option(struct loadparm_context *lp_ctx, const char *option)
{
char *p, *s;
bool ret;
@ -1920,7 +1921,7 @@ bool lp_set_option(const char *option)
*p = 0;
ret = lp_set_cmdline(s, p+1);
ret = lp_set_cmdline(lp_ctx, s, p+1);
free(s);
return ret;
}
@ -2052,7 +2053,7 @@ static bool do_section(const char *pszSectionName, void *userdata)
/* issued by the post-processing of a previous section. */
DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
if ((loadparm.currentService = add_a_service(lp_ctx, &sDefault,
if ((lp_ctx->currentService = add_a_service(lp_ctx, &sDefault,
pszSectionName))
== NULL) {
DEBUG(0, ("Failed to add a new service\n"));
@ -2099,7 +2100,7 @@ static bool is_default(int i)
Display the contents of the global structure.
***************************************************************************/
static void dump_globals(FILE *f, bool show_defaults)
static void dump_globals(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults)
{
int i;
struct param_opt *data;
@ -2116,8 +2117,8 @@ static void dump_globals(FILE *f, bool show_defaults)
print_parameter(&parm_table[i], parm_table[i].ptr, f);
fprintf(f, "\n");
}
if (loadparm.Globals.param_opt != NULL) {
for (data = loadparm.Globals.param_opt; data;
if (lp_ctx->Globals.param_opt != NULL) {
for (data = lp_ctx->Globals.param_opt; data;
data = data->next) {
fprintf(f, "\t%s = %s\n", data->key, data->value);
}
@ -2168,9 +2169,10 @@ static void dump_a_service(struct loadparm_service * pService, FILE * f)
}
}
bool lp_dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
bool lp_dump_a_parameter(struct loadparm_context *lp_ctx, int snum, char *parm_name, FILE * f,
bool isGlobal)
{
struct loadparm_service * pService = loadparm.ServicePtrs[snum];
struct loadparm_service * pService = lp_ctx->ServicePtrs[snum];
struct parm_struct *parm;
void *ptr;
@ -2196,7 +2198,8 @@ bool lp_dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal)
Return NULL when out of parameters.
***************************************************************************/
struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
int allparameters)
{
if (snum == -1) {
/* do the globals */
@ -2216,7 +2219,7 @@ struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
return &parm_table[(*i)++];
}
} else {
struct loadparm_service *pService = loadparm.ServicePtrs[snum];
struct loadparm_service *pService = lp_ctx->ServicePtrs[snum];
for (; parm_table[*i].label; (*i)++) {
if (parm_table[*i].class == P_SEPARATOR)
@ -2273,16 +2276,18 @@ bool lp_loaded(void)
Unload unused services.
***************************************************************************/
void lp_killunused(struct smbsrv_connection *smb, bool (*snumused) (struct smbsrv_connection *, int))
void lp_killunused(struct loadparm_context *lp_ctx,
struct smbsrv_connection *smb,
bool (*snumused) (struct smbsrv_connection *, int))
{
int i;
for (i = 0; i < loadparm.iNumServices; i++) {
if (loadparm.ServicePtrs[i] == NULL)
for (i = 0; i < lp_ctx->iNumServices; i++) {
if (lp_ctx->ServicePtrs[i] == NULL)
continue;
if (!snumused || !snumused(smb, i)) {
talloc_free(loadparm.ServicePtrs[i]);
loadparm.ServicePtrs[i] = NULL;
talloc_free(lp_ctx->ServicePtrs[i]);
lp_ctx->ServicePtrs[i] = NULL;
}
}
}
@ -2532,7 +2537,7 @@ void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
if (show_defaults)
defaults_saved = false;
dump_globals(f, show_defaults);
dump_globals(lp_ctx, f, show_defaults);
dump_a_service(&sDefault, f);

View File

@ -200,7 +200,7 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
return -1;
}
mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(argv[0], argv[1])));
mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(global_loadparm, argv[0], argv[1])));
return 0;
}

View File

@ -52,7 +52,7 @@ int main(int argc, const char **argv)
fault_setup(argv[0]);
if (getenv("SMB_CONF_PATH")) {
lp_set_cmdline("config file", getenv("SMB_CONF_PATH"));
lp_set_cmdline(global_loadparm, "config file", getenv("SMB_CONF_PATH"));
}
ldb_global_init();

View File

@ -1445,7 +1445,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
nt_status_support = lp_nt_status_support();
if (!lp_set_cmdline("nt status support", "yes")) {
if (!lp_set_cmdline(global_loadparm, "nt status support", "yes")) {
torture_comment(tctx, "Could not set 'nt status support = yes'\n");
goto fail;
}
@ -1454,7 +1454,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
goto fail;
}
if (!lp_set_cmdline("nt status support", "no")) {
if (!lp_set_cmdline(global_loadparm, "nt status support", "no")) {
torture_comment(tctx, "Could not set 'nt status support = yes'\n");
goto fail;
}
@ -1463,7 +1463,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx)
goto fail;
}
if (!lp_set_cmdline("nt status support",
if (!lp_set_cmdline(global_loadparm, "nt status support",
nt_status_support ? "yes":"no")) {
torture_comment(tctx, "Could not reset 'nt status support = yes'");
goto fail;

View File

@ -215,7 +215,7 @@ static BOOL irpc_setup(struct torture_context *tctx, void **_data)
*_data = data = talloc(tctx, struct irpc_test_data);
lp_set_cmdline("pid directory", "piddir.tmp");
lp_set_cmdline(global_loadparm, "pid directory", "piddir.tmp");
data->ev = tctx->ev;
torture_assert(tctx, data->msg_ctx1 =

View File

@ -68,7 +68,7 @@ static bool test_ping_speed(struct torture_context *tctx)
uint32_t msg_ping, msg_exit;
TALLOC_CTX *mem_ctx = tctx;
lp_set_cmdline("pid directory", "piddir.tmp");
lp_set_cmdline(global_loadparm, "pid directory", "piddir.tmp");
ev = tctx->ev;

View File

@ -614,10 +614,10 @@ static void usage(void)
exact_error_codes = True;
break;
case 'l':
lp_set_cmdline("torture:unclist", optarg);
lp_set_cmdline(global_loadparm, "torture:unclist", optarg);
break;
case 'W':
lp_set_cmdline("workgroup", optarg);
lp_set_cmdline(global_loadparm, "workgroup", optarg);
break;
case 'h':
usage();

View File

@ -285,7 +285,7 @@ static void usage(void)
setup_logging("masktest", DEBUG_STDOUT);
lp_set_cmdline("log level", "0");
lp_set_cmdline(global_loadparm, "log level", "0");
if (argc < 2 || argv[1][0] == '-') {
usage();
@ -325,7 +325,7 @@ static void usage(void)
verbose++;
break;
case 'M':
lp_set_cmdline("max protocol", optarg);
lp_set_cmdline(global_loadparm, "max protocol", optarg);
break;
case 'U':
cli_credentials_parse_string(credentials, optarg, CRED_SPECIFIED);

View File

@ -892,7 +892,7 @@ bool torture_raw_context(struct torture_context *torture,
bool ret = true;
if (lp_use_spnego()) {
ret &= torture_raw_context_int(torture, cli);
lp_set_cmdline("use spnego", "False");
lp_set_cmdline(global_loadparm, "use spnego", "False");
}
ret &= torture_raw_context_int(torture, cli);

View File

@ -346,7 +346,7 @@ bool torture_samba3_badpath(struct torture_context *torture)
nt_status_support = lp_nt_status_support();
if (!lp_set_cmdline("nt status support", "yes")) {
if (!lp_set_cmdline(global_loadparm, "nt status support", "yes")) {
printf("Could not set 'nt status support = yes'\n");
goto fail;
}
@ -355,7 +355,7 @@ bool torture_samba3_badpath(struct torture_context *torture)
goto fail;
}
if (!lp_set_cmdline("nt status support", "no")) {
if (!lp_set_cmdline(global_loadparm, "nt status support", "no")) {
printf("Could not set 'nt status support = yes'\n");
goto fail;
}
@ -364,7 +364,7 @@ bool torture_samba3_badpath(struct torture_context *torture)
goto fail;
}
if (!lp_set_cmdline("nt status support",
if (!lp_set_cmdline(global_loadparm, "nt status support",
nt_status_support ? "yes":"no")) {
printf("Could not reset 'nt status support = yes'");
goto fail;

View File

@ -228,7 +228,7 @@ BOOL torture_rpc_mgmt(struct torture_context *torture)
continue;
}
lp_set_cmdline("torture:binding", dcerpc_binding_string(loop_ctx, b));
lp_set_cmdline(global_loadparm, "torture:binding", dcerpc_binding_string(loop_ctx, b));
status = torture_rpc_connection(torture, &p, &ndr_table_mgmt);
if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {

View File

@ -131,7 +131,7 @@ bool torture_rpc_scanner(struct torture_context *torture)
b->endpoint = talloc_strdup(b, l->table->name);
}
lp_set_cmdline("torture:binding", dcerpc_binding_string(torture, b));
lp_set_cmdline(global_loadparm, "torture:binding", dcerpc_binding_string(torture, b));
status = torture_rpc_connection(torture, &p, &ndr_table_mgmt);
if (!NT_STATUS_IS_OK(status)) {

View File

@ -148,9 +148,9 @@ static bool test_secrets(struct torture_context *torture, const void *_data)
const struct secret_settings *settings =
(const struct secret_settings *)_data;
lp_set_cmdline("ntlmssp client:keyexchange", settings->keyexchange?"True":"False");
lp_set_cmdline("ntlmssp_client:ntlm2", settings->ntlm2?"True":"False");
lp_set_cmdline("ntlmssp_client:lm_key", settings->lm_key?"True":"False");
lp_set_cmdline(global_loadparm, "ntlmssp client:keyexchange", settings->keyexchange?"True":"False");
lp_set_cmdline(global_loadparm, "ntlmssp_client:ntlm2", settings->ntlm2?"True":"False");
lp_set_cmdline(global_loadparm, "ntlmssp_client:lm_key", settings->lm_key?"True":"False");
torture_assert_ntstatus_ok(torture, torture_rpc_binding(torture, &binding),
"Getting bindoptions");

View File

@ -224,7 +224,7 @@ static bool test_RFFPCNEx(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, dcerpc_register_ep_server(&ep_server),
"unable to register spoolss server");
lp_set_cmdline("dcerpc endpoint servers", "spoolss");
lp_set_cmdline(global_loadparm, "dcerpc endpoint servers", "spoolss");
address = iface_n_ip(0);
torture_comment(tctx, "Listening for callbacks on %s\n", address);

View File

@ -131,33 +131,33 @@ static void parse_dns(const char *dns)
/* retrievieng the userdn */
p = strchr_m(dns, '#');
if (!p) {
lp_set_cmdline("torture:ldap_userdn", "");
lp_set_cmdline("torture:ldap_basedn", "");
lp_set_cmdline("torture:ldap_secret", "");
lp_set_cmdline(global_loadparm, "torture:ldap_userdn", "");
lp_set_cmdline(global_loadparm, "torture:ldap_basedn", "");
lp_set_cmdline(global_loadparm, "torture:ldap_secret", "");
return;
}
userdn = strndup(dns, p - dns);
lp_set_cmdline("torture:ldap_userdn", userdn);
lp_set_cmdline(global_loadparm, "torture:ldap_userdn", userdn);
/* retrieve the basedn */
d = p + 1;
p = strchr_m(d, '#');
if (!p) {
lp_set_cmdline("torture:ldap_basedn", "");
lp_set_cmdline("torture:ldap_secret", "");
lp_set_cmdline(global_loadparm, "torture:ldap_basedn", "");
lp_set_cmdline(global_loadparm, "torture:ldap_secret", "");
return;
}
basedn = strndup(d, p - d);
lp_set_cmdline("torture:ldap_basedn", basedn);
lp_set_cmdline(global_loadparm, "torture:ldap_basedn", basedn);
/* retrieve the secret */
p = p + 1;
if (!p) {
lp_set_cmdline("torture:ldap_secret", "");
lp_set_cmdline(global_loadparm, "torture:ldap_secret", "");
return;
}
secret = strdup(p);
lp_set_cmdline("torture:ldap_secret", secret);
lp_set_cmdline(global_loadparm, "torture:ldap_secret", secret);
printf ("%s - %s - %s\n", userdn, basedn, secret);
@ -448,7 +448,7 @@ void run_shell(struct torture_context *tctx)
fprintf(stderr, "Usage: set <variable> <value>\n");
} else {
char *name = talloc_asprintf(NULL, "torture:%s", argv[1]);
lp_set_cmdline(name, argv[2]);
lp_set_cmdline(global_loadparm, name, argv[2]);
talloc_free(name);
}
} else if (!strcmp(argv[0], "help")) {
@ -538,36 +538,36 @@ int main(int argc,char *argv[])
while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_LOADFILE:
lp_set_cmdline("torture:loadfile", poptGetOptArg(pc));
lp_set_cmdline(global_loadparm, "torture:loadfile", poptGetOptArg(pc));
break;
case OPT_UNCLIST:
lp_set_cmdline("torture:unclist", poptGetOptArg(pc));
lp_set_cmdline(global_loadparm, "torture:unclist", poptGetOptArg(pc));
break;
case OPT_TIMELIMIT:
lp_set_cmdline("torture:timelimit", poptGetOptArg(pc));
lp_set_cmdline(global_loadparm, "torture:timelimit", poptGetOptArg(pc));
break;
case OPT_NUMPROGS:
lp_set_cmdline("torture:nprocs", poptGetOptArg(pc));
lp_set_cmdline(global_loadparm, "torture:nprocs", poptGetOptArg(pc));
break;
case OPT_DNS:
parse_dns(poptGetOptArg(pc));
break;
case OPT_DANGEROUS:
lp_set_cmdline("torture:dangerous", "Yes");
lp_set_cmdline(global_loadparm, "torture:dangerous", "Yes");
break;
case OPT_ASYNC:
lp_set_cmdline("torture:async", "Yes");
lp_set_cmdline(global_loadparm, "torture:async", "Yes");
break;
case OPT_SMB_PORTS:
lp_set_cmdline("smb ports", poptGetOptArg(pc));
lp_set_cmdline(global_loadparm, "smb ports", poptGetOptArg(pc));
break;
}
}
if (strcmp(target, "samba3") == 0) {
lp_set_cmdline("torture:samba3", "true");
lp_set_cmdline(global_loadparm, "torture:samba3", "true");
} else if (strcmp(target, "samba4") == 0) {
lp_set_cmdline("torture:samba4", "true");
lp_set_cmdline(global_loadparm, "torture:samba4", "true");
}
if (max_runtime) {
@ -632,14 +632,14 @@ int main(int argc,char *argv[])
usage(pc);
return false;
}
lp_set_cmdline("torture:host", binding_struct->host);
lp_set_cmdline(global_loadparm, "torture:host", binding_struct->host);
if (lp_parm_string(NULL, "torture", "share") == NULL)
lp_set_cmdline("torture:share", "IPC$");
lp_set_cmdline("torture:binding", argv_new[1]);
lp_set_cmdline(global_loadparm, "torture:share", "IPC$");
lp_set_cmdline(global_loadparm, "torture:binding", argv_new[1]);
} else {
lp_set_cmdline("torture:host", host);
lp_set_cmdline("torture:share", share);
lp_set_cmdline("torture:binding", host);
lp_set_cmdline(global_loadparm, "torture:host", host);
lp_set_cmdline(global_loadparm, "torture:share", share);
lp_set_cmdline(global_loadparm, "torture:binding", host);
}
if (!strcmp(ui_ops_name, "simple")) {

View File

@ -643,7 +643,7 @@ double torture_create_procs(struct torture_context *tctx,
srandom(((int)mypid) ^ ((int)time(NULL)));
asprintf(&myname, "CLIENT%d", i);
lp_set_cmdline("netbios name", myname);
lp_set_cmdline(global_loadparm, "netbios name", myname);
free(myname);

View File

@ -137,7 +137,7 @@ static int do_global_checks(void)
*/
/* We need this to force the output */
lp_set_cmdline("log level", "2");
lp_set_cmdline(global_loadparm, "log level", "2");
fprintf(stderr,"Load smb config files from %s\n",lp_configfile());
@ -212,7 +212,7 @@ static int do_global_checks(void)
if (!parameter_name) {
lp_dump_one(stdout, show_defaults, service);
} else {
ret = !lp_dump_a_parameter(s, parameter_name, stdout, (service == NULL));
ret = !lp_dump_a_parameter(global_loadparm, s, parameter_name, stdout, (service == NULL));
}
} else {
lp_dump(global_loadparm, stdout, show_defaults, lp_numservices(global_loadparm));