mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
r8561: as with the other ejs subsystems, make nss into a object
This commit is contained in:
parent
da366042f4
commit
a3f3292e66
@ -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
|
||||
*/
|
||||
@ -136,13 +136,28 @@ 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);
|
||||
}
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user