Author: jelmer Date: 2007-12-04 00:12:13 +0000 (Tue, 04 Dec 2007) New Revision: 26275
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26275 Log: return loadparm context in lp_load. Modified: branches/SAMBA_4_0/ branches/SAMBA_4_0/source/client/smbmount.c branches/SAMBA_4_0/source/client/smbspool.c branches/SAMBA_4_0/source/lib/cmdline/popt_common.c branches/SAMBA_4_0/source/param/loadparm.c branches/SAMBA_4_0/source/scripting/ejs/smbcalls_config.c branches/SAMBA_4_0/source/scripting/ejs/smbscript.c branches/SAMBA_4_0/source/torture/gentest.c branches/SAMBA_4_0/source/torture/locktest.c branches/SAMBA_4_0/source/torture/locktest2.c branches/SAMBA_4_0/source/torture/masktest.c branches/SAMBA_4_0/source/utils/testparm.c Changeset: Property changes on: branches/SAMBA_4_0 ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/SAMBA_4_0/source/client/smbmount.c =================================================================== --- branches/SAMBA_4_0/source/client/smbmount.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/client/smbmount.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -323,7 +323,8 @@ * not exit after open_sockets() or send_login() errors, * as the smbfs mount would then have no way to recover. */ -static void send_fs_socket(const char *the_service, const char *mount_point, struct smbcli_state *c) +static void send_fs_socket(struct loadparm_context *lp_ctx, + const char *the_service, const char *mount_point, struct smbcli_state *c) { int fd, closed = 0, res = 1; pid_t parentpid = getppid(); @@ -407,7 +408,7 @@ pause(); DEBUG(2,("mount.smbfs[%d]: got signal, getting new socket\n", sys_getpid())); c = do_connection(the_service, - lp_unicode(global_loadparm), + lp_unicode(lp_ctx), lp_cli_maxprotocol(global_loadparm)); } } @@ -529,7 +530,7 @@ for any reason, we will have to unmount the mount point. There is no exit from the next call... */ - send_fs_socket(service, mount_point, c); + send_fs_socket(global_loadparm, service, mount_point, c); } @@ -852,6 +853,7 @@ extern char *optarg; extern int optind; char *p; + struct loadparm_context *lp_ctx; DEBUGLEVEL = 1; @@ -882,7 +884,7 @@ } if (getenv("PASSWD")) { - pstrcpy(password,getenv("PASSWD")); + pstrcpy(password, getenv("PASSWD")); got_pass = true; } @@ -895,7 +897,7 @@ pstrcpy(username,getenv("LOGNAME")); } - if (!lp_load(dyn_CONFIGFILE)) { + if (!lp_load(dyn_CONFIGFILE, &lp_ctx)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", lp_config_file()); } Modified: branches/SAMBA_4_0/source/client/smbspool.c =================================================================== --- branches/SAMBA_4_0/source/client/smbspool.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/client/smbspool.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -50,6 +50,7 @@ FILE *fp; /* File to print */ int status=0; /* Status of LPD job */ struct smbcli_state *cli; /* SMB interface */ + struct loadparm_context *lp_ctx; /* we expect the URI in argv[0]. Detect the case where it is in argv[1] and cope */ if (argc > 2 && strncmp(argv[0],"smb://", 6) && !strncmp(argv[1],"smb://", 6)) { @@ -176,13 +177,13 @@ setup_logging(argv[0], DEBUG_STDOUT); - if (!lp_load(dyn_CONFIGFILE)) { + if (!lp_load(dyn_CONFIGFILE, &lp_ctx)) { fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file()); return (1); } if (workgroup == NULL) - workgroup = lp_workgroup(); + workgroup = lp_workgroup(lp_ctx); do { Modified: branches/SAMBA_4_0/source/lib/cmdline/popt_common.c =================================================================== --- branches/SAMBA_4_0/source/lib/cmdline/popt_common.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/lib/cmdline/popt_common.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -52,9 +52,9 @@ if (reason == POPT_CALLBACK_REASON_POST) { if (!lp_loaded()) { if (getenv("SMB_CONF_PATH")) - lp_load(getenv("SMB_CONF_PATH")); + lp_load(getenv("SMB_CONF_PATH"), NULL); else - lp_load(dyn_CONFIGFILE); + lp_load(dyn_CONFIGFILE, NULL); } /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ @@ -101,7 +101,7 @@ case 's': if (arg) { - lp_load(arg); + lp_load(arg, NULL); } break; Modified: branches/SAMBA_4_0/source/param/loadparm.c =================================================================== --- branches/SAMBA_4_0/source/param/loadparm.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/param/loadparm.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -2407,7 +2407,7 @@ _PUBLIC_ _DEPRECATED_ bool lp_load_default(void) { - return lp_load(dyn_CONFIGFILE); + return lp_load(dyn_CONFIGFILE, NULL); } /*************************************************************************** @@ -2415,13 +2415,16 @@ False on failure. ***************************************************************************/ -bool lp_load(const char *filename) +bool lp_load(const char *filename, struct loadparm_context **ret_lp) { char *n2; bool bRetval; struct param_opt *data; struct loadparm_context *lp_ctx = &loadparm; + if (ret_lp != NULL) + *ret_lp = NULL; + filename = talloc_strdup(talloc_autofree_context(), filename); global_loadparm = lp_ctx; @@ -2470,6 +2473,9 @@ close_iconv(); + if (ret_lp != NULL) + *ret_lp = lp_ctx; + return bRetval; } Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls_config.c =================================================================== --- branches/SAMBA_4_0/source/scripting/ejs/smbcalls_config.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/scripting/ejs/smbcalls_config.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -187,7 +187,9 @@ */ static int ejs_lpReload(MprVarHandle eid, int argc, char **argv) { - bool ret = lp_load(lp_configfile(global_loadparm)); + bool ret; + + ret = lp_load(lp_configfile(global_loadparm), NULL); if (ret) { unload_interfaces(); } Modified: branches/SAMBA_4_0/source/scripting/ejs/smbscript.c =================================================================== --- branches/SAMBA_4_0/source/scripting/ejs/smbscript.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/scripting/ejs/smbscript.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -49,18 +49,19 @@ const char *fname; struct MprVar *return_var; int exit_status, i; + struct loadparm_context *lp_ctx; fault_setup(argv[0]); if (getenv("SMB_CONF_PATH")) { - lp_load(getenv("SMB_CONF_PATH")); + lp_load(getenv("SMB_CONF_PATH"), &lp_ctx); } else { - lp_load(dyn_CONFIGFILE); + lp_load(dyn_CONFIGFILE, &lp_ctx); } ldb_global_init(); - gensec_init(global_loadparm); + gensec_init(lp_ctx); mprSetCtx(mem_ctx); Modified: branches/SAMBA_4_0/source/torture/gentest.c =================================================================== --- branches/SAMBA_4_0/source/torture/gentest.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/torture/gentest.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -2172,6 +2172,7 @@ int opt; int i, username_count=0; bool ret; + struct loadparm_context *lp_ctx; setlinebuf(stdout); @@ -2196,12 +2197,12 @@ argc -= NSERVERS; argv += NSERVERS; - lp_load(dyn_CONFIGFILE); + lp_load(dyn_CONFIGFILE, &lp_ctx); servers[0].credentials = cli_credentials_init(talloc_autofree_context()); servers[1].credentials = cli_credentials_init(talloc_autofree_context()); - cli_credentials_guess(servers[0].credentials, global_loadparm); - cli_credentials_guess(servers[1].credentials, global_loadparm); + cli_credentials_guess(servers[0].credentials, lp_ctx); + cli_credentials_guess(servers[1].credentials, lp_ctx); options.seed = time(NULL); options.numops = 1000; @@ -2265,7 +2266,7 @@ } } - gensec_init(global_loadparm); + gensec_init(lp_ctx); if (username_count == 0) { usage(); Modified: branches/SAMBA_4_0/source/torture/locktest.c =================================================================== --- branches/SAMBA_4_0/source/torture/locktest.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/torture/locktest.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -543,6 +543,7 @@ int opt; int seed, server; int username_count=0; + struct loadparm_context *lp_ctx; setlinebuf(stdout); @@ -563,12 +564,12 @@ argc -= NSERVERS; argv += NSERVERS; - lp_load(dyn_CONFIGFILE); + lp_load(dyn_CONFIGFILE, &lp_ctx); servers[0] = cli_credentials_init(talloc_autofree_context()); servers[1] = cli_credentials_init(talloc_autofree_context()); - cli_credentials_guess(servers[0], global_loadparm); - cli_credentials_guess(servers[1], global_loadparm); + cli_credentials_guess(servers[0], lp_ctx); + cli_credentials_guess(servers[1], lp_ctx); seed = time(NULL); @@ -617,10 +618,10 @@ exact_error_codes = true; break; case 'l': - lp_set_cmdline(global_loadparm, "torture:unclist", optarg); + lp_set_cmdline(lp_ctx, "torture:unclist", optarg); break; case 'W': - lp_set_cmdline(global_loadparm, "workgroup", optarg); + lp_set_cmdline(lp_ctx, "workgroup", optarg); break; case 'h': usage(); @@ -639,7 +640,7 @@ servers[1] = servers[0]; } - gensec_init(global_loadparm); + gensec_init(lp_ctx); argc -= optind; argv += optind; Modified: branches/SAMBA_4_0/source/torture/locktest2.c =================================================================== --- branches/SAMBA_4_0/source/torture/locktest2.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/torture/locktest2.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -460,6 +460,7 @@ int opt; char *p; int seed; + struct loadparm_context *lp_ctx; setlinebuf(stdout); @@ -483,7 +484,7 @@ argc -= 4; argv += 4; - lp_load(dyn_CONFIGFILE); + lp_load(dyn_CONFIGFILE, &lp_ctx); if (getenv("USER")) { fstrcpy(username,getenv("USER")); Modified: branches/SAMBA_4_0/source/torture/masktest.c =================================================================== --- branches/SAMBA_4_0/source/torture/masktest.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/torture/masktest.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -281,6 +281,7 @@ struct smbcli_state *cli; int opt; int seed; + struct loadparm_context *lp_ctx; setlinebuf(stdout); @@ -302,10 +303,10 @@ argc -= 1; argv += 1; - lp_load(dyn_CONFIGFILE); + lp_load(dyn_CONFIGFILE, &lp_ctx); credentials = cli_credentials_init(talloc_autofree_context()); - cli_credentials_guess(credentials, global_loadparm); + cli_credentials_guess(credentials, lp_ctx); seed = time(NULL); @@ -326,7 +327,7 @@ verbose++; break; case 'M': - lp_set_cmdline(global_loadparm, "max protocol", optarg); + lp_set_cmdline(lp_ctx, "max protocol", optarg); break; case 'U': cli_credentials_parse_string(credentials, optarg, CRED_SPECIFIED); @@ -358,7 +359,7 @@ } } - gensec_init(global_loadparm); + gensec_init(lp_ctx); argc -= optind; argv += optind; Modified: branches/SAMBA_4_0/source/utils/testparm.c =================================================================== --- branches/SAMBA_4_0/source/utils/testparm.c 2007-12-04 00:12:03 UTC (rev 26274) +++ branches/SAMBA_4_0/source/utils/testparm.c 2007-12-04 00:12:13 UTC (rev 26275) @@ -184,6 +184,7 @@ static const char *cname; static const char *caddr; static bool show_defaults = false; + struct loadparm_context *lp_ctx; struct poptOption long_options[] = { POPT_AUTOHELP @@ -238,15 +239,15 @@ fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm)); - if (!lp_load(lp_configfile(global_loadparm))) { + if (!lp_load(lp_configfile(global_loadparm), &lp_ctx)) { fprintf(stderr,"Error loading services.\n"); return(1); } fprintf(stderr,"Loaded services file OK.\n"); - ret = do_global_checks(global_loadparm); - ret |= do_share_checks(global_loadparm, cname, caddr, silent_mode, show_defaults, section_name, parameter_name); + ret = do_global_checks(lp_ctx); + ret |= do_share_checks(lp_ctx, cname, caddr, silent_mode, show_defaults, section_name, parameter_name); return(ret); }