summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-19 00:16:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:38 -0500
commitf1245d4ac1f06988dc4501c14c0e8161be8028aa (patch)
treed0f840c350f14919b056d9e31dbb08bb5ce4df81
parent948183cb389195827892c5960b4cbcb3d1f8a645 (diff)
downloadsamba-f1245d4ac1f06988dc4501c14c0e8161be8028aa.tar.gz
samba-f1245d4ac1f06988dc4501c14c0e8161be8028aa.tar.bz2
samba-f1245d4ac1f06988dc4501c14c0e8161be8028aa.zip
r8561: as with the other ejs subsystems, make nss into a object
(This used to be commit a3f3292e6698ce9be6a5036f47dd4fa81a1dfd4e)
-rw-r--r--source4/scripting/ejs/smbcalls_nss.c31
-rw-r--r--source4/scripting/libjs/provision.js12
2 files changed, 30 insertions, 13 deletions
diff --git a/source4/scripting/ejs/smbcalls_nss.c b/source4/scripting/ejs/smbcalls_nss.c
index 212eb88eb4..a804c14b7f 100644
--- a/source4/scripting/ejs/smbcalls_nss.c
+++ b/source4/scripting/ejs/smbcalls_nss.c
@@ -68,7 +68,7 @@ static struct MprVar mpr_group(struct group *grp)
/*
usage:
- var pw = getpwnam("root");
+ var pw = nss.getpwnam("root");
returns an object containing struct passwd entries
*/
@@ -86,7 +86,7 @@ static int ejs_getpwnam(MprVarHandle eid, int argc, struct MprVar **argv)
/*
usage:
- var pw = getpwuid(0);
+ var pw = nss.getpwuid(0);
returns an object containing struct passwd entries
*/
@@ -103,7 +103,7 @@ static int ejs_getpwuid(MprVarHandle eid, int argc, struct MprVar **argv)
/*
usage:
- var pw = getgrnam("users");
+ var pw = nss.getgrnam("users");
returns an object containing struct group entries
*/
@@ -120,7 +120,7 @@ static int ejs_getgrnam(MprVarHandle eid, int argc, struct MprVar **argv)
/*
usage:
- var pw = getgrgid(0);
+ var pw = nss.getgrgid(0);
returns an object containing struct group entries
*/
@@ -137,12 +137,27 @@ static int ejs_getgrgid(MprVarHandle eid, int argc, struct MprVar **argv)
/*
+ initialise nss ejs subsystem
+*/
+static int ejs_nss_init(MprVarHandle eid, int argc, struct MprVar **argv)
+{
+ struct MprVar *nss;
+ mpr_Return(eid, mprObject("nss"));
+
+ nss = ejsGetReturnValue(eid);
+
+ mprSetCFunction(nss, "getpwnam", ejs_getpwnam);
+ mprSetCFunction(nss, "getpwuid", ejs_getpwuid);
+ mprSetCFunction(nss, "getgrnam", ejs_getgrnam);
+ mprSetCFunction(nss, "getgrgid", ejs_getgrgid);
+
+ return 0;
+}
+
+/*
setup C functions that be called from ejs
*/
void smb_setup_ejs_nss(void)
{
- ejsDefineCFunction(-1, "getpwnam", ejs_getpwnam, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "getpwuid", ejs_getpwuid, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "getgrnam", ejs_getgrnam, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "getgrgid", ejs_getgrgid, NULL, MPR_VAR_SCRIPT_HANDLE);
+ ejsDefineCFunction(-1, "nss_init", ejs_nss_init, NULL, MPR_VAR_SCRIPT_HANDLE);
}
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
index c7fb1b5fc5..7133e50b4c 100644
--- a/source4/scripting/libjs/provision.js
+++ b/source4/scripting/libjs/provision.js
@@ -196,6 +196,8 @@ function provision(subobj, message)
function provision_guess()
{
var subobj = new Object();
+ var nss = nss_init();
+
subobj.REALM = lpGet("realm");
subobj.DOMAIN = lpGet("workgroup");
subobj.HOSTNAME = hostname();
@@ -213,11 +215,11 @@ function provision_guess()
subobj.LDAPTIME = ldaptime;
subobj.DATESTRING = datestring;
subobj.USN = nextusn;
- subobj.ROOT = findnss(getpwnam, "root");
- subobj.NOBODY = findnss(getpwnam, "nobody");
- subobj.NOGROUP = findnss(getgrnam, "nogroup", "nobody");
- subobj.WHEEL = findnss(getgrnam, "wheel", "root");
- subobj.USERS = findnss(getgrnam, "users", "guest", "other");
+ subobj.ROOT = findnss(nss.getpwnam, "root");
+ subobj.NOBODY = findnss(nss.getpwnam, "nobody");
+ subobj.NOGROUP = findnss(nss.getgrnam, "nogroup", "nobody");
+ subobj.WHEEL = findnss(nss.getgrnam, "wheel", "root");
+ subobj.USERS = findnss(nss.getgrnam, "users", "guest", "other");
subobj.DNSDOMAIN = strlower(subobj.REALM);
subobj.DNSNAME = sprintf("%s.%s",
strlower(subobj.HOSTNAME),