summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-08 23:32:37 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:48:56 +0100
commitdd7e5ed88c48f4ee39e53be07c8839791e914e45 (patch)
treefca88a741257b2f5165f3762de6c44053888fc3e /source4
parent75ac6cd318ae58aacc77785ba93af50bfe354b63 (diff)
downloadsamba-dd7e5ed88c48f4ee39e53be07c8839791e914e45.tar.gz
samba-dd7e5ed88c48f4ee39e53be07c8839791e914e45.tar.bz2
samba-dd7e5ed88c48f4ee39e53be07c8839791e914e45.zip
r26352: Don't make lp_load create a new context.
(This used to be commit d0d5c1a823a6601292c061dba2b6f4bde2b9e3dd)
Diffstat (limited to 'source4')
-rw-r--r--source4/client/smbmount.c6
-rw-r--r--source4/client/smbspool.c4
-rw-r--r--source4/lib/cmdline/popt_common.c23
-rw-r--r--source4/param/loadparm.c31
-rw-r--r--source4/scripting/ejs/smbcalls_config.c14
-rw-r--r--source4/scripting/ejs/smbscript.c6
-rw-r--r--source4/scripting/libjs/provision.js2
-rw-r--r--source4/scripting/libjs/upgrade.js1
-rw-r--r--source4/torture/gentest.c3
-rw-r--r--source4/torture/locktest.c3
-rw-r--r--source4/torture/locktest2.c3
-rw-r--r--source4/torture/masktest.c3
-rw-r--r--source4/utils/testparm.c10
13 files changed, 62 insertions, 47 deletions
diff --git a/source4/client/smbmount.c b/source4/client/smbmount.c
index b32bcf5b68..0c1c330104 100644
--- a/source4/client/smbmount.c
+++ b/source4/client/smbmount.c
@@ -897,7 +897,9 @@ static void parse_mount_smb(int argc, char **argv)
pstrcpy(username,getenv("LOGNAME"));
}
- if (!lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx)) {
+ lp_ctx = global_loadparm = loadparm_init(talloc_autofree_context());
+
+ if (!lp_load(lp_ctx, dyn_CONFIGFILE)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
lp_config_file());
}
@@ -923,6 +925,6 @@ static void parse_mount_smb(int argc, char **argv)
}
strupper(my_netbios_name);
- init_mount(global_loadparm);
+ init_mount(lp_ctx);
return 0;
}
diff --git a/source4/client/smbspool.c b/source4/client/smbspool.c
index 0951fb2bef..80a11d5f2d 100644
--- a/source4/client/smbspool.c
+++ b/source4/client/smbspool.c
@@ -177,7 +177,9 @@ static int smb_print(struct smbcli_state *, char *, FILE *);
setup_logging(argv[0], DEBUG_STDOUT);
- if (!lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx)) {
+ global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context());
+
+ if (!lp_load(lp_ctx, dyn_CONFIGFILE)) {
fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file());
return (1);
}
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c
index 2bbb59dbda..73b3eecfbf 100644
--- a/source4/lib/cmdline/popt_common.c
+++ b/source4/lib/cmdline/popt_common.c
@@ -40,6 +40,7 @@
enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL,OPT_DEBUG_STDERR};
struct cli_credentials *cmdline_credentials = NULL;
+struct loadparm_context *cmdline_lp_ctx = NULL;
static void popt_version_callback(poptContext con,
enum poptCallbackReason reason,
@@ -59,14 +60,13 @@ static void popt_samba_callback(poptContext con,
const char *arg, const void *data)
{
const char *pname;
- struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */
if (reason == POPT_CALLBACK_REASON_POST) {
- if (lp_ctx == NULL) {
+ if (lp_configfile(cmdline_lp_ctx) == NULL) {
if (getenv("SMB_CONF_PATH"))
- lp_load(talloc_autofree_context(), getenv("SMB_CONF_PATH"), &lp_ctx);
+ lp_load(cmdline_lp_ctx, getenv("SMB_CONF_PATH"));
else
- lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx);
+ lp_load(cmdline_lp_ctx, dyn_CONFIGFILE);
}
/* Hook any 'every Samba program must do this, after
* the smb.conf is setup' functions here */
@@ -82,6 +82,11 @@ static void popt_samba_callback(poptContext con,
pname++;
if (reason == POPT_CALLBACK_REASON_PRE) {
+ if (global_loadparm != NULL) {
+ cmdline_lp_ctx = global_loadparm;
+ } else {
+ cmdline_lp_ctx = global_loadparm = loadparm_init(talloc_autofree_context());
+ }
/* Hook for 'almost the first thing to do in a samba program' here */
/* setup for panics */
@@ -104,14 +109,14 @@ static void popt_samba_callback(poptContext con,
break;
case OPT_OPTION:
- if (!lp_set_option(lp_ctx, arg)) {
+ if (!lp_set_option(cmdline_lp_ctx, arg)) {
fprintf(stderr, "Error setting option '%s'\n", arg);
exit(1);
}
break;
case 'd':
- lp_set_cmdline(lp_ctx, "log level", arg);
+ lp_set_cmdline(cmdline_lp_ctx, "log level", arg);
break;
case OPT_DEBUG_STDERR:
@@ -120,14 +125,14 @@ static void popt_samba_callback(poptContext con,
case 's':
if (arg) {
- lp_load(talloc_autofree_context(), arg, NULL);
+ lp_load(cmdline_lp_ctx, arg);
}
break;
case 'l':
if (arg) {
char *new_logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname);
- lp_set_cmdline(lp_ctx, "log file", new_logfile);
+ lp_set_cmdline(cmdline_lp_ctx, "log file", new_logfile);
talloc_free(new_logfile);
}
break;
@@ -143,7 +148,7 @@ static void popt_common_callback(poptContext con,
const struct poptOption *opt,
const char *arg, const void *data)
{
- struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */
+ struct loadparm_context *lp_ctx = cmdline_lp_ctx;
switch(opt->val) {
case 'O':
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index b045269192..564dede3a5 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -88,7 +88,6 @@ struct loadparm_global
char *szServerString;
char *szAutoServices;
char *szPasswdChat;
- const char *szConfigFile;
char *szShareBackend;
char *szSAM_URL;
char *szSECRETS_URL;
@@ -356,8 +355,6 @@ static const struct enum_list enum_server_role[] = {
#define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
static struct parm_struct parm_table[] = {
- {"config file", P_STRING, P_GLOBAL, GLOBAL_VAR(szConfigFile), NULL, NULL},
-
{"server role", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_role), NULL, enum_server_role},
{"dos charset", P_STRING, P_GLOBAL, GLOBAL_VAR(dos_charset), NULL, NULL},
@@ -521,6 +518,7 @@ static struct parm_struct parm_table[] = {
/* local variables */
struct loadparm_context {
+ const char *szConfigFile;
struct loadparm_global *globals;
struct loadparm_service **services;
int iNumServices;
@@ -682,7 +680,6 @@ _PUBLIC_ FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)
_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_support, bWINSsupport)
_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_dns_proxy, bWINSdnsProxy)
_PUBLIC_ FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)
-_PUBLIC_ FN_GLOBAL_STRING(lp_configfile, szConfigFile)
_PUBLIC_ FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)
_PUBLIC_ FN_GLOBAL_BOOL(lp_readraw, bReadRaw)
_PUBLIC_ FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)
@@ -2399,35 +2396,30 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
return lp_ctx;
}
+const char *lp_configfile(struct loadparm_context *lp_ctx)
+{
+ return lp_ctx->szConfigFile;
+}
+
/**
* Load the services array from the services file.
*
* Return True on success, False on failure.
*/
-bool lp_load(TALLOC_CTX *mem_ctx, const char *filename, struct loadparm_context **ret_lp)
+bool lp_load(struct loadparm_context *lp_ctx, const char *filename)
{
char *n2;
bool bRetval;
- struct loadparm_context *lp_ctx;
-
- if (ret_lp != NULL)
- *ret_lp = NULL;
-
- lp_ctx = loadparm_init(mem_ctx);
- if (lp_ctx == NULL)
- return false;
-
- global_loadparm = lp_ctx;
filename = talloc_strdup(lp_ctx, filename);
- lp_ctx->globals->szConfigFile = filename;
+ lp_ctx->szConfigFile = filename;
lp_ctx->bInGlobalSection = true;
- n2 = standard_sub_basic(lp_ctx, lp_ctx->globals->szConfigFile);
+ n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
DEBUG(2, ("lp_load: refreshing parameters from %s\n", n2));
- add_to_file_list(lp_ctx, lp_ctx->globals->szConfigFile, n2);
+ add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
/* We get sections first, so have to start 'behind' to make up */
lp_ctx->currentService = NULL;
@@ -2452,9 +2444,6 @@ bool lp_load(TALLOC_CTX *mem_ctx, const char *filename, struct loadparm_context
reload_charcnv();
- if (ret_lp != NULL)
- *ret_lp = lp_ctx;
-
return bRetval;
}
diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c
index 157587186c..88c153ead3 100644
--- a/source4/scripting/ejs/smbcalls_config.c
+++ b/source4/scripting/ejs/smbcalls_config.c
@@ -161,6 +161,14 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
return 0;
}
+/*
+ v = lp.filename(); obtain filename
+*/
+static int ejs_lpFilename(MprVarHandle eid, int argc, char **argv)
+{
+ mpr_ReturnString(eid, lp_configfile(global_loadparm));
+ return 0;
+}
/*
set a smb.conf parameter. Only sets in memory, not permanent
@@ -188,8 +196,9 @@ static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
static int ejs_lpReload(MprVarHandle eid, int argc, char **argv)
{
bool ret;
-
- ret = lp_load(talloc_autofree_context(), lp_configfile(global_loadparm), NULL);
+ const char *filename = lp_configfile(global_loadparm);
+
+ ret = lp_load(global_loadparm, filename);
if (ret) {
unload_interfaces();
}
@@ -208,6 +217,7 @@ static int ejs_loadparm_init(MprVarHandle eid, int argc, struct MprVar **argv)
mprSetStringCFunction(obj, "set", ejs_lpSet);
mprSetStringCFunction(obj, "reload", ejs_lpReload);
mprSetStringCFunction(obj, "services", ejs_lpServices);
+ mprSetStringCFunction(obj, "filename", ejs_lpFilename);
return 0;
}
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c
index e00d52589a..a4f2e1cd43 100644
--- a/source4/scripting/ejs/smbscript.c
+++ b/source4/scripting/ejs/smbscript.c
@@ -53,10 +53,12 @@ int main(int argc, const char **argv)
fault_setup(argv[0]);
+ global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context());
+
if (getenv("SMB_CONF_PATH")) {
- lp_load(talloc_autofree_context(), getenv("SMB_CONF_PATH"), &lp_ctx);
+ lp_load(lp_ctx, getenv("SMB_CONF_PATH"));
} else {
- lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx);
+ lp_load(lp_ctx, dyn_CONFIGFILE);
}
ldb_global_init();
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
index 7d77bf7885..f9814884f3 100644
--- a/source4/scripting/libjs/provision.js
+++ b/source4/scripting/libjs/provision.js
@@ -386,7 +386,7 @@ function provision_default_paths(subobj)
var dnsdomain = strlower(subobj.REALM);
var lp = loadparm_init();
var paths = new Object();
- paths.smbconf = lp.get("config file");
+ paths.smbconf = lp.filename()
paths.shareconf = lp.get("private dir") + "/" + "share.ldb";
paths.samdb = lp.get("sam database");
paths.secrets = lp.get("secrets database");
diff --git a/source4/scripting/libjs/upgrade.js b/source4/scripting/libjs/upgrade.js
index 3504d850f2..3a548fe34b 100644
--- a/source4/scripting/libjs/upgrade.js
+++ b/source4/scripting/libjs/upgrade.js
@@ -468,7 +468,6 @@ smbconf_keep = new Array(
"wins support",
"csc policy",
"strict locking",
- "config file",
"preload",
"auto services",
"lock dir",
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index c1e33820af..e8e531a119 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -2197,7 +2197,8 @@ static bool split_unc_name(const char *unc, char **server, char **share)
argc -= NSERVERS;
argv += NSERVERS;
- lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx);
+ global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context());
+ lp_load(lp_ctx, dyn_CONFIGFILE);
servers[0].credentials = cli_credentials_init(talloc_autofree_context());
servers[1].credentials = cli_credentials_init(talloc_autofree_context());
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index a53422fb44..d51c2692d7 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -565,7 +565,8 @@ static void usage(void)
argc -= NSERVERS;
argv += NSERVERS;
- lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx);
+ global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context());
+ lp_load(lp_ctx, dyn_CONFIGFILE);
servers[0] = cli_credentials_init(talloc_autofree_context());
servers[1] = cli_credentials_init(talloc_autofree_context());
diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c
index e8b0170f91..19629d8770 100644
--- a/source4/torture/locktest2.c
+++ b/source4/torture/locktest2.c
@@ -484,7 +484,8 @@ static void usage(void)
argc -= 4;
argv += 4;
- lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx);
+ global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context());
+ lp_load(lp_ctx, dyn_CONFIGFILE);
if (getenv("USER")) {
fstrcpy(username,getenv("USER"));
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index 402ea4ae9c..612b96e4f7 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -303,7 +303,8 @@ static void usage(void)
argc -= 1;
argv += 1;
- lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx);
+ lp_ctx = global_loadparm = loadparm_init(talloc_autofree_context());
+ lp_load(lp_ctx, dyn_CONFIGFILE);
credentials = cli_credentials_init(talloc_autofree_context());
cli_credentials_guess(credentials, lp_ctx);
diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c
index bd4bc79240..fe8cc7124a 100644
--- a/source4/utils/testparm.c
+++ b/source4/utils/testparm.c
@@ -141,7 +141,7 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c
if (!parameter_name) {
lp_dump_one(stdout, show_defaults, service);
} else {
- ret = !lp_dump_a_parameter(lp_ctx, service, parameter_name, stdout, (service == NULL));
+ ret = !lp_dump_a_parameter(lp_ctx, service, parameter_name, stdout);
}
} else {
lp_dump(lp_ctx, stdout, show_defaults, lp_numservices(lp_ctx));
@@ -233,13 +233,15 @@ static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, c
set_local_machine_name(new_local_machine, True);
}
*/
+
+ lp_ctx = global_loadparm;
/* We need this to force the output */
- lp_set_cmdline(global_loadparm, "log level", "2");
+ lp_set_cmdline(lp_ctx, "log level", "2");
- fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm));
+ fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(lp_ctx));
- if (!lp_load(talloc_autofree_context(), lp_configfile(global_loadparm), &lp_ctx)) {
+ if (!lp_load(lp_ctx, lp_configfile(lp_ctx))) {
fprintf(stderr,"Error loading services.\n");
return(1);
}