summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsource4/scripting/bin/smbstatus4
-rw-r--r--source4/scripting/ejs/smbcalls_config.c15
-rw-r--r--source4/scripting/libjs/auth.js3
-rw-r--r--source4/scripting/libjs/management.js3
-rw-r--r--source4/scripting/libjs/provision.js16
-rw-r--r--swat/esptest/ldb.esp3
-rw-r--r--swat/esptest/loadparm.esp11
-rw-r--r--testprogs/ejs/loadparm.js7
8 files changed, 42 insertions, 20 deletions
diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus
index 7fefae6963..38f2ab06a9 100755
--- a/source4/scripting/bin/smbstatus
+++ b/source4/scripting/bin/smbstatus
@@ -82,7 +82,9 @@ function show_nbt()
println("");
}
-printf("%s\n\n", lpGet("server string"));
+var lp = loadparm_init();
+
+printf("%s\n\n", lp.get("server string"));
if (options['nbt'] != undefined) {
show_nbt();
diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c
index 18bdd0547e..7fc58f237d 100644
--- a/source4/scripting/ejs/smbcalls_config.c
+++ b/source4/scripting/ejs/smbcalls_config.c
@@ -140,10 +140,21 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
}
/*
+ initialise loadparm ejs subsystem
+*/
+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, "services", ejs_lpServices);
+ return 0;
+}
+
+/*
setup C functions that be called from ejs
*/
void smb_setup_ejs_config(void)
{
- ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, MPR_VAR_SCRIPT_HANDLE);
+ ejsDefineCFunction(-1, "loadparm_init", ejs_loadparm_init, NULL, MPR_VAR_SCRIPT_HANDLE);
}
diff --git a/source4/scripting/libjs/auth.js b/source4/scripting/libjs/auth.js
index a973cb4753..73d8645218 100644
--- a/source4/scripting/libjs/auth.js
+++ b/source4/scripting/libjs/auth.js
@@ -11,7 +11,8 @@
function getDomainList()
{
var ret = new Array(2);
+ var lp = loadparm_init();
ret[0] = "System User";
- ret[1] = lpGet("workgroup");
+ ret[1] = lp.get("workgroup");
return ret;
}
diff --git a/source4/scripting/libjs/management.js b/source4/scripting/libjs/management.js
index 7130cdc5dd..e1c68ca1de 100644
--- a/source4/scripting/libjs/management.js
+++ b/source4/scripting/libjs/management.js
@@ -97,7 +97,8 @@ function nbtd_statistics()
*/
function service_enabled(name)
{
- var services = lpGet("server services");
+ var lp = loadparm_init();
+ var services = lp.get("server services");
var i;
for (i=0;i<services.length;i++) {
if (services[i] == name) {
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
index d3b94c1d1c..e9a8aad0cc 100644
--- a/source4/scripting/libjs/provision.js
+++ b/source4/scripting/libjs/provision.js
@@ -141,13 +141,14 @@ function setup_ldb(ldif, dbname, subobj)
{
var extra = "";
var ldb = ldb_init();
+ var lp = loadparm_init();
if (arguments.length == 4) {
extra = arguments[3];
}
var dbfile = dbname;
- var src = lpGet("setup directory") + "/" + ldif;
+ var src = lp.get("setup directory") + "/" + ldif;
var data = sys.file_load(src);
data = data + extra;
@@ -167,8 +168,9 @@ function setup_ldb(ldif, dbname, subobj)
*/
function setup_file(template, fname, subobj)
{
- var f = lpGet("private dir") + "/" + fname;
- var src = lpGet("setup directory") + "/" + template;
+ var lp = loadparm_init();
+ var f = lp.get("private dir") + "/" + fname;
+ var src = lp.get("setup directory") + "/" + template;
sys.unlink(f);
@@ -221,9 +223,10 @@ function provision_guess()
{
var subobj = new Object();
var nss = nss_init();
+ var lp = loadparm_init();
- subobj.REALM = lpGet("realm");
- subobj.DOMAIN = lpGet("workgroup");
+ subobj.REALM = lp.get("realm");
+ subobj.DOMAIN = lp.get("workgroup");
subobj.HOSTNAME = hostname();
subobj.HOSTIP = hostip();
subobj.DOMAINGUID = randguid();
@@ -271,7 +274,8 @@ function searchone(ldb, expression, attribute)
*/
function newuser(username, unixname, password, message)
{
- var samdb = lpGet("sam database");
+ var lp = loadparm_init();
+ var samdb = lp.get("sam database");
var ldb = ldb_init();
/* connect to the sam */
diff --git a/swat/esptest/ldb.esp b/swat/esptest/ldb.esp
index b0a2db8dad..20b95b1590 100644
--- a/swat/esptest/ldb.esp
+++ b/swat/esptest/ldb.esp
@@ -5,7 +5,8 @@
<h3>An attribute constrained search</h3>
<%
-var dbfile = lpGet("sam database");
+var lp = loadparm_init();
+var dbfile = lp.get("sam database");
var attrs = new Array("name", "dnsDomain", "objectSid", "dn");
var ldb = ldb_init();
var ok = ldb.connect(dbfile);
diff --git a/swat/esptest/loadparm.esp b/swat/esptest/loadparm.esp
index 9e6de480e2..9ea83b77bc 100644
--- a/swat/esptest/loadparm.esp
+++ b/swat/esptest/loadparm.esp
@@ -3,6 +3,8 @@
<h1>Samba4 loadparm test</h1>
<%
+lp = loadparm_init();
+
var f = FormObj("LoadparmTest", 2, 1);
f.element[0].label = "Share";
f.element[1].label = "Parameter";
@@ -41,9 +43,9 @@ if (request['REQUEST_METHOD'] == "POST") {
share = form['Share'];
name = form['Parameter'];
if (share && name) {
- v = lpGet(share, name);
+ v = lp.get(share, name);
} else if (name) {
- v = lpGet(name);
+ v = lp.get(name);
}
showValue(name, v);
@@ -53,11 +55,10 @@ if (request['REQUEST_METHOD'] == "POST") {
Here are some commonly used parameters:<p>
<%
-
-showValue("defined services", lpServices());
+showValue("defined services", lp.services());
function showParameter(name) {
- showValue(name, lpGet(name));
+ showValue(name, lp.get(name));
}
showParameter("server services");
diff --git a/testprogs/ejs/loadparm.js b/testprogs/ejs/loadparm.js
index 6c2a80bb73..f56ca9f7fc 100644
--- a/testprogs/ejs/loadparm.js
+++ b/testprogs/ejs/loadparm.js
@@ -2,9 +2,11 @@
demonstrate access to loadparm functions from ejs
*/
+loadparm_init(local);
+
function showParameter(name) {
print(name + ": ");
- printVars(lpGet(name));
+ printVars(get(name));
}
for (v in ARGV) {
@@ -12,7 +14,7 @@ for (v in ARGV) {
}
print("defined services: ");
-printVars(lpServices());
+printVars(services());
showParameter("server services");
showParameter("netbios name");
@@ -21,4 +23,3 @@ showParameter("workgroup");
showParameter("log level");
showParameter("server signing");
showParameter("interfaces");
-