mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Add setgid,getgid
This commit is contained in:
1 parent
4fd0225e41
commit
df1c1e593f
2 files changed
+30
No files matched your search
@@ -138,6 +138,9 @@ Returns the current working directory of the process.
|
||||
+process.getuid(), process.setuid(id)+::
|
||||
Gets/sets the user identity of the process. (See setuid(2).)
|
||||
|
||||
+process.getgid(), process.setgid(id)+::
|
||||
Gets/sets the group identity of the process. (See setgid(2).)
|
||||
|
||||
+process.chdir(directory)+::
|
||||
Changes the current working directory of the process.
|
||||
|
||||
|
||||
+27
@@ -488,6 +488,29 @@ static Handle<Value> GetUid(const Arguments& args) {
|
||||
return scope.Close(Integer::New(uid));
|
||||
}
|
||||
|
||||
static Handle<Value> GetGid(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
int gid = getgid();
|
||||
return scope.Close(Integer::New(gid));
|
||||
}
|
||||
|
||||
|
||||
static Handle<Value> SetGid(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
if (args.Length() < 1) {
|
||||
return ThrowException(Exception::Error(
|
||||
String::New("setgid requires 1 argument")));
|
||||
}
|
||||
|
||||
Local<Integer> given_gid = args[0]->ToInteger();
|
||||
int gid = given_gid->Int32Value();
|
||||
int result;
|
||||
if ((result == setgid(gid)) != 0) {
|
||||
return ThrowException(Exception::Error(String::New(strerror(errno))));
|
||||
}
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
static Handle<Value> SetUid(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
@@ -1034,6 +1057,10 @@ static void Load(int argc, char *argv[]) {
|
||||
NODE_SET_METHOD(process, "cwd", Cwd);
|
||||
NODE_SET_METHOD(process, "getuid", GetUid);
|
||||
NODE_SET_METHOD(process, "setuid", SetUid);
|
||||
|
||||
NODE_SET_METHOD(process, "setgid", SetGid);
|
||||
NODE_SET_METHOD(process, "getgid", GetGid);
|
||||
|
||||
NODE_SET_METHOD(process, "umask", Umask);
|
||||
NODE_SET_METHOD(process, "dlopen", DLOpen);
|
||||
NODE_SET_METHOD(process, "kill", Kill);
|
||||
|
||||
Reference in new issue
Block a user