diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-20 10:07:48 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:29:48 -0500 |
commit | 2f5f01567b4c30cd764843a1ca0c7ab6d9bc0882 (patch) | |
tree | 52876d17edf8162d20c8da7c1761cd0fbb0e0db1 /source4/scripting | |
parent | 238a7e2f4c46f5bb586bcef36f39e1bf6749c2c1 (diff) | |
download | samba-2f5f01567b4c30cd764843a1ca0c7ab6d9bc0882.tar.gz samba-2f5f01567b4c30cd764843a1ca0c7ab6d9bc0882.tar.bz2 samba-2f5f01567b4c30cd764843a1ca0c7ab6d9bc0882.zip |
r8643: - make lp_configfile() work again
- get rid of redundeny dyn_CONFIGFILE argument to lp_load()
- fixed provisioning to work with completely pristine install,
creating an initial smb.conf is none is present
- added lp.set() and lp.reload() to loadparm ejs object interface
(This used to be commit c2691ef7126ddcee5f95970b78759b40a049d0a7)
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/ejs/smbcalls_config.c | 45 | ||||
-rw-r--r-- | source4/scripting/ejs/smbscript.c | 2 | ||||
-rw-r--r-- | source4/scripting/libjs/provision.js | 21 |
3 files changed, 61 insertions, 7 deletions
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(); |