summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/client/smbmount.c4
-rw-r--r--source4/client/smbspool.c7
-rw-r--r--source4/gtk/tools/gepdump.c2
-rw-r--r--source4/gtk/tools/gregedit.c2
-rw-r--r--source4/gtk/tools/gwcrontab.c2
-rw-r--r--source4/gtk/tools/gwsam.c2
-rw-r--r--source4/lib/cmdline/popt_common.c4
-rw-r--r--source4/param/loadparm.c17
-rw-r--r--source4/scripting/ejs/smbcalls_config.c45
-rw-r--r--source4/scripting/ejs/smbscript.c2
-rw-r--r--source4/scripting/libjs/provision.js21
-rwxr-xr-xsource4/setup/provision6
-rw-r--r--source4/torture/gentest.c2
-rw-r--r--source4/torture/locktest.c2
-rw-r--r--source4/torture/locktest2.c2
-rw-r--r--source4/torture/masktest.c2
-rw-r--r--source4/torture/msgtest.c2
-rw-r--r--swat/install/provision.esp13
18 files changed, 104 insertions, 33 deletions
diff --git a/source4/client/smbmount.c b/source4/client/smbmount.c
index 77cd04c3c3..b2e6b9677f 100644
--- a/source4/client/smbmount.c
+++ b/source4/client/smbmount.c
@@ -894,9 +894,9 @@ static void parse_mount_smb(int argc, char **argv)
pstrcpy(username,getenv("LOGNAME"));
}
- if (!lp_load(dyn_CONFIGFILE)) {
+ if (!lp_load()) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
- dyn_CONFIGFILE);
+ lp_config_file());
}
parse_mount_smb(argc, argv);
diff --git a/source4/client/smbspool.c b/source4/client/smbspool.c
index 2703205d7d..21dc5c0e10 100644
--- a/source4/client/smbspool.c
+++ b/source4/client/smbspool.c
@@ -177,10 +177,9 @@ static int smb_print(struct smbcli_state *, char *, FILE *);
setup_logging("smbspool", DEBUG_STDOUT);
- if (!lp_load(dyn_CONFIGFILE))
- {
- fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
- return (1);
+ if (!lp_load()) {
+ fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file());
+ return (1);
}
if (workgroup == NULL)
diff --git a/source4/gtk/tools/gepdump.c b/source4/gtk/tools/gepdump.c
index 23d95152f4..12ca93905d 100644
--- a/source4/gtk/tools/gepdump.c
+++ b/source4/gtk/tools/gepdump.c
@@ -463,7 +463,7 @@ static GtkWidget* create_mainwindow (void)
int main(int argc, char **argv)
{
gepdump_init_subsystems;
- lp_load(dyn_CONFIGFILE);
+ lp_load();
load_interfaces();
setup_logging(argv[0], DEBUG_STDERR);
diff --git a/source4/gtk/tools/gregedit.c b/source4/gtk/tools/gregedit.c
index 27ae925746..5501059c5a 100644
--- a/source4/gtk/tools/gregedit.c
+++ b/source4/gtk/tools/gregedit.c
@@ -977,7 +977,7 @@ int main(int argc, char *argv[])
int ret;
gregedit_init_subsystems;
- lp_load(dyn_CONFIGFILE);
+ lp_load();
load_interfaces();
setup_logging(argv[0], DEBUG_STDERR);
diff --git a/source4/gtk/tools/gwcrontab.c b/source4/gtk/tools/gwcrontab.c
index 5b79eafa0a..c8d8fd6929 100644
--- a/source4/gtk/tools/gwcrontab.c
+++ b/source4/gtk/tools/gwcrontab.c
@@ -495,7 +495,7 @@ static GtkWidget*create_new_job_dialog (void)
int main(int argc, char **argv)
{
gwcrontab_init_subsystems;
- lp_load(dyn_CONFIGFILE);
+ lp_load();
load_interfaces();
setup_logging(argv[0], DEBUG_STDERR);
diff --git a/source4/gtk/tools/gwsam.c b/source4/gtk/tools/gwsam.c
index 8606cc398f..96e405c3a5 100644
--- a/source4/gtk/tools/gwsam.c
+++ b/source4/gtk/tools/gwsam.c
@@ -403,7 +403,7 @@ static GtkWidget* create_mainwindow (void)
int main(int argc, char **argv)
{
gwsam_init_subsystems;
- lp_load(dyn_CONFIGFILE);
+ lp_load();
load_interfaces();
setup_logging(argv[0], DEBUG_STDERR);
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c
index b7b7bdc286..e39c8e964d 100644
--- a/source4/lib/cmdline/popt_common.c
+++ b/source4/lib/cmdline/popt_common.c
@@ -52,7 +52,7 @@ static void popt_common_callback(poptContext con,
if (reason == POPT_CALLBACK_REASON_POST) {
/* Hook any 'every Samba program must do this, after
* the smb.conf is setup' functions here */
- lp_load(dyn_CONFIGFILE);
+ lp_load();
load_interfaces();
return;
}
@@ -92,7 +92,7 @@ static void popt_common_callback(poptContext con,
case 's':
if (arg) {
- pstrcpy(dyn_CONFIGFILE, arg);
+ lp_set_cmdline("config file", arg);
}
break;
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 354318b2bd..160a7d12de 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -910,6 +910,8 @@ static void init_globals(void)
}
}
+ do_parameter("config file", dyn_CONFIGFILE);
+
/* options that can be set on the command line must be initialised via
the slower do_parameter() to ensure that FLAG_CMDLINE is obeyed */
#ifdef TCP_NODELAY
@@ -2985,21 +2987,14 @@ static void set_server_role(void)
False on failure.
***************************************************************************/
-BOOL lp_load(const char *pszFname)
+BOOL lp_load(void)
{
pstring n2;
BOOL bRetval;
struct param_opt *data;
- pstrcpy(n2, pszFname);
- standard_sub_basic(n2,sizeof(n2));
-
- add_to_file_list(pszFname, n2);
-
bRetval = False;
- DEBUG(2, ("lp_load: refreshing parameters from %s\n", pszFname));
-
bInGlobalSection = True;
if (Globals.param_opt != NULL) {
@@ -3016,6 +3011,12 @@ BOOL lp_load(const char *pszFname)
init_globals();
+ pstrcpy(n2, lp_configfile());
+ standard_sub_basic(n2,sizeof(n2));
+ DEBUG(2, ("lp_load: refreshing parameters from %s\n", n2));
+
+ add_to_file_list(lp_configfile(), n2);
+
/* We get sections first, so have to start 'behind' to make up */
iServiceIndex = -1;
bRetval = pm_process(n2, do_section, do_parameter);
diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c
index 7fc58f237d..ddb06aa7d7 100644
--- a/source4/scripting/ejs/smbcalls_config.c
+++ b/source4/scripting/ejs/smbcalls_config.c
@@ -24,6 +24,7 @@
#include "scripting/ejs/smbcalls.h"
#include "lib/appweb/ejs/ejs.h"
#include "param/loadparm.h"
+#include "dynconfig.h"
/*
return a list of defined services
@@ -48,10 +49,10 @@ static int ejs_lpServices(MprVarHandle eid, int argc, char **argv)
can be called in 4 ways:
- v = lpGet("type:parm"); gets a parametric variable
- v = lpGet("share", "type:parm"); gets a parametric variable on a share
- v = lpGet("parm"); gets a global variable
- v = lpGet("share", "parm"); gets a share variable
+ v = lp.get("type:parm"); gets a parametric variable
+ v = lp.get("share", "type:parm"); gets a parametric variable on a share
+ v = lp.get("parm"); gets a global variable
+ v = lp.get("share", "parm"); gets a share variable
the returned variable is a ejs object. It is an array object for lists.
*/
@@ -139,6 +140,40 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
return 0;
}
+
+/*
+ set a smb.conf parameter. Only sets in memory, not permanent
+
+ can be called in 4 ways:
+
+ ok = lp.set("parm", "value");
+*/
+static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
+{
+ if (argc != 2) {
+ ejsSetErrorMsg(eid, "lp.set invalid arguments");
+ return -1;
+ }
+
+ mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(argv[0], argv[1])));
+ return 0;
+}
+
+/*
+ reload smb.conf
+
+ ok = lp.reload();
+*/
+static int ejs_lpReload(MprVarHandle eid, int argc, char **argv)
+{
+ BOOL ret = lp_load();
+ if (ret) {
+ load_interfaces();
+ }
+ mpr_Return(eid, mprCreateBoolVar(ret));
+ return 0;
+}
+
/*
initialise loadparm ejs subsystem
*/
@@ -147,6 +182,8 @@ static int ejs_loadparm_init(MprVarHandle eid, int argc, struct MprVar **argv)
struct MprVar *obj = mprInitObject(eid, "loadparm", argc, argv);
mprSetStringCFunction(obj, "get", ejs_lpGet);
+ mprSetStringCFunction(obj, "set", ejs_lpSet);
+ mprSetStringCFunction(obj, "reload", ejs_lpReload);
mprSetStringCFunction(obj, "services", ejs_lpServices);
return 0;
}
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c
index 8359629a85..c6155dcbeb 100644
--- a/source4/scripting/ejs/smbscript.c
+++ b/source4/scripting/ejs/smbscript.c
@@ -48,7 +48,7 @@ void ejs_exception(const char *reason)
smbscript_init_subsystems;
mprSetCtx(mem_ctx);
- lp_load(dyn_CONFIGFILE);
+ lp_load();
if (argc < 2) {
fprintf(stderr, "You must supply a script name\n");
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
index 58f0e18240..f5aaeafe89 100644
--- a/source4/scripting/libjs/provision.js
+++ b/source4/scripting/libjs/provision.js
@@ -169,7 +169,7 @@ function setup_ldb(ldif, dbname, subobj)
function setup_file(template, fname, subobj)
{
var lp = loadparm_init();
- var f = lp.get("private dir") + "/" + fname;
+ var f = fname;
var src = lp.get("setup directory") + "/" + template;
sys.unlink(f);
@@ -187,6 +187,9 @@ function setup_file(template, fname, subobj)
function provision(subobj, message)
{
var data = "";
+ var lp = loadparm_init();
+ var sys = sys_init();
+ var smbconf = lp.get("config file");
/*
some options need to be upper/lower case
@@ -204,6 +207,13 @@ function provision(subobj, message)
provision_next_usn = 1;
+ /* only install a new smb.conf if there isn't one there already */
+ var st = sys.stat(smbconf);
+ if (st == undefined) {
+ message("Setting up smb.conf\n");
+ setup_file("provision.smb.conf", smbconf, subobj);
+ lp.reload();
+ }
message("Setting up hklm.ldb\n");
setup_ldb("hklm.ldif", "hklm.ldb", subobj);
message("Setting up sam.ldb\n");
@@ -213,7 +223,9 @@ function provision(subobj, message)
message("Setting up secrets.ldb\n");
setup_ldb("secrets.ldif", "secrets.ldb", subobj);
message("Setting up DNS zone file\n");
- setup_file("provision.zone", subobj.DNSDOMAIN + ".zone", subobj);
+ setup_file("provision.zone",
+ lp.get("private dir") + "/" + subobj.DNSDOMAIN + ".zone",
+ subobj);
}
/*
@@ -229,6 +241,11 @@ function provision_guess()
subobj.REALM = lp.get("realm");
subobj.DOMAIN = lp.get("workgroup");
subobj.HOSTNAME = hostname();
+
+ assert(subobj.REALM);
+ assert(subobj.DOMAIN);
+ assert(subobj.HOSTNAME);
+
subobj.HOSTIP = hostip();
subobj.DOMAINGUID = randguid();
subobj.DOMAINSID = randsid();
diff --git a/source4/setup/provision b/source4/setup/provision
index 7cd05538b5..90363fcf20 100755
--- a/source4/setup/provision
+++ b/source4/setup/provision
@@ -92,6 +92,12 @@ if (options["realm"] == undefined ||
ShowHelp();
}
+/* cope with an initially blank smb.conf */
+var lp = loadparm_init();
+lp.set("realm", options.realm);
+lp.set("workgroup", options.domain);
+lp.reload();
+
var subobj = provision_guess();
for (r in options) {
var key = strupper(join("", split("-", r)));
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index 6adcbbc0fe..8b0e995b44 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -2127,7 +2127,7 @@ static void usage(void)
argc -= NSERVERS;
argv += NSERVERS;
- lp_load(dyn_CONFIGFILE);
+ lp_load();
load_interfaces();
servers[0].credentials = cli_credentials_init(talloc_autofree_context());
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index 62eabeb688..65fadfcc7d 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -476,7 +476,7 @@ static void usage(void)
argc -= NSERVERS;
argv += NSERVERS;
- lp_load(dyn_CONFIGFILE);
+ lp_load();
load_interfaces();
servers[0] = cli_credentials_init(talloc_autofree_context());
diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c
index e5cd8a60af..062861a75f 100644
--- a/source4/torture/locktest2.c
+++ b/source4/torture/locktest2.c
@@ -484,7 +484,7 @@ static void usage(void)
argc -= 4;
argv += 4;
- lp_load(dyn_CONFIGFILE);
+ lp_load();
load_interfaces();
if (getenv("USER")) {
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index 4ad280eac7..8b1c0699ee 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -296,7 +296,7 @@ static void usage(void)
argc -= 1;
argv += 1;
- lp_load(dyn_CONFIGFILE);
+ lp_load();
load_interfaces();
credentials = cli_credentials_init(talloc_autofree_context());
diff --git a/source4/torture/msgtest.c b/source4/torture/msgtest.c
index fa47eca1ba..92c62b8e9f 100644
--- a/source4/torture/msgtest.c
+++ b/source4/torture/msgtest.c
@@ -41,7 +41,7 @@ void pong_message(int msg_type, pid_t src, void *buf, size_t len)
setup_logging(argv[0], DEBUG_STDOUT);
- lp_load(dyn_CONFIGFILE);
+ lp_load();
message_init();
diff --git a/swat/install/provision.esp b/swat/install/provision.esp
index 5c0aa4e77e..3eb7ba720d 100644
--- a/swat/install/provision.esp
+++ b/swat/install/provision.esp
@@ -8,7 +8,15 @@
<%
var f = FormObj("Provisioning", 9, 2);
-var i, subobj = provision_guess();
+var i;
+var lp = loadparm_init();
+
+if (lp.get("realm") == "") {
+ lp.set("realm", lp.get("workgroup") + ".example.com");
+}
+
+
+var subobj = provision_guess();
f.element[0].label = "Realm";
f.element[0].name = "REALM";
@@ -44,6 +52,9 @@ if (form['submit'] == "Provision") {
for (i=0;i<f.element.length;i++) {
f.element[i].value = subobj[f.element[i].name];
}
+
+lp.set("realm", subobj.REALM);
+
if (form['submit'] == "Provision") {
provision(subobj, writefln);
} else {