Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-12-23 05:08:20 +0300
committerRyan Dahl <ry@tinyclouds.org>2011-01-11 21:02:58 +0300
commit6f5d95de6df6dad23b908fb15ad1a823b9d9a4d1 (patch)
treec914f3b6933d084c05a28748fefc7e681b5b5ef1 /lib
parentb7419dfaadc512f46898f4ca8dae30b19fede83f (diff)
child_process: Add gid/uid flags to spawn config
This is mostly working, but not completely ideal for two reasons. 1. Rather than emitting an error on the ChildProcess object when the setgid/setuid fails, it is simply printing the error to stderr and exiting. The same happens with the cwd, so that's not completely terrible. 2. I don't have a good test for this. It fails with an EPERM if you try to change the uid or gid as a non-root user.
Diffstat (limited to 'lib')
-rw-r--r--lib/child_process.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/child_process.js b/lib/child_process.js
index e20e80ef0cd..520961fd1a9 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -185,21 +185,27 @@ ChildProcess.prototype.kill = function(sig) {
ChildProcess.prototype.spawn = function(path, args, options, customFds) {
args = args || [];
- var cwd, env, setsid;
+ var cwd, env, setsid, uid, gid;
if (!options || options.cwd === undefined &&
options.env === undefined &&
- options.customFds === undefined) {
+ options.customFds === undefined &&
+ options.gid === undefined &&
+ options.uid === undefined) {
// Deprecated API: (path, args, options, env, customFds)
cwd = '';
env = options || process.env;
customFds = customFds || [-1, -1, -1];
setsid = false;
+ uid = -1;
+ gid = -1;
} else {
// Recommended API: (path, args, options)
cwd = options.cwd || '';
env = options.env || process.env;
customFds = options.customFds || [-1, -1, -1];
setsid = options.setsid ? true : false;
+ uid = options.hasOwnProperty("uid") ? options.uid : -1;
+ gid = options.hasOwnProperty("gid") ? options.gid : -1;
}
var envPairs = [];
@@ -214,7 +220,9 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) {
cwd,
envPairs,
customFds,
- setsid);
+ setsid,
+ uid,
+ gid);
this.fds = fds;
if (customFds[0] === -1 || customFds[0] === undefined) {