diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-19 00:16:43 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:29:38 -0500 |
commit | f1245d4ac1f06988dc4501c14c0e8161be8028aa (patch) | |
tree | d0f840c350f14919b056d9e31dbb08bb5ce4df81 /source4/scripting/ejs | |
parent | 948183cb389195827892c5960b4cbcb3d1f8a645 (diff) | |
download | samba-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)
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r-- | source4/scripting/ejs/smbcalls_nss.c | 31 |
1 files changed, 23 insertions, 8 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); } |