Add process.setuid(), getuid()
This commit is contained in:
parent
6f92d8f3b0
commit
a38607605c
@ -136,6 +136,9 @@ success code 0.
|
|||||||
+process.cwd()+::
|
+process.cwd()+::
|
||||||
Returns the current working directory of the process.
|
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.chdir(directory)+::
|
+process.chdir(directory)+::
|
||||||
Changes the current working directory of the process.
|
Changes the current working directory of the process.
|
||||||
|
|
||||||
|
30
src/node.cc
30
src/node.cc
@ -9,6 +9,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <dlfcn.h> /* dlopen(), dlsym() */
|
#include <dlfcn.h> /* dlopen(), dlsym() */
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h> /* setuid, getuid */
|
||||||
|
|
||||||
#include <node_events.h>
|
#include <node_events.h>
|
||||||
#include <node_dns.h>
|
#include <node_dns.h>
|
||||||
@ -464,6 +466,32 @@ static Handle<Value> Umask(const Arguments& args){
|
|||||||
return scope.Close(Uint32::New(old));
|
return scope.Close(Uint32::New(old));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static Handle<Value> GetUid(const Arguments& args) {
|
||||||
|
HandleScope scope;
|
||||||
|
int uid = getuid();
|
||||||
|
return scope.Close(Integer::New(uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static Handle<Value> SetUid(const Arguments& args) {
|
||||||
|
HandleScope scope;
|
||||||
|
|
||||||
|
if (args.Length() < 1) {
|
||||||
|
return ThrowException(Exception::Error(
|
||||||
|
String::New("setuid requires 1 argument")));
|
||||||
|
}
|
||||||
|
|
||||||
|
Local<Integer> given_uid = args[0]->ToInteger();
|
||||||
|
int uid = given_uid->Int32Value();
|
||||||
|
int result;
|
||||||
|
if ((result = setuid(uid)) != 0) {
|
||||||
|
return ThrowException(Exception::Error(String::New(strerror(errno))));
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
v8::Handle<v8::Value> Exit(const v8::Arguments& args) {
|
v8::Handle<v8::Value> Exit(const v8::Arguments& args) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
@ -953,6 +981,8 @@ static void Load(int argc, char *argv[]) {
|
|||||||
NODE_SET_METHOD(process, "reallyExit", Exit);
|
NODE_SET_METHOD(process, "reallyExit", Exit);
|
||||||
NODE_SET_METHOD(process, "chdir", Chdir);
|
NODE_SET_METHOD(process, "chdir", Chdir);
|
||||||
NODE_SET_METHOD(process, "cwd", Cwd);
|
NODE_SET_METHOD(process, "cwd", Cwd);
|
||||||
|
NODE_SET_METHOD(process, "getuid", GetUid);
|
||||||
|
NODE_SET_METHOD(process, "setuid", SetUid);
|
||||||
NODE_SET_METHOD(process, "umask", Umask);
|
NODE_SET_METHOD(process, "umask", Umask);
|
||||||
NODE_SET_METHOD(process, "dlopen", DLOpen);
|
NODE_SET_METHOD(process, "dlopen", DLOpen);
|
||||||
NODE_SET_METHOD(process, "kill", Kill);
|
NODE_SET_METHOD(process, "kill", Kill);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user