Skip to content

Commit

Permalink
child_process: accept uid/gid everywhere
Browse files Browse the repository at this point in the history
Accept uid/gid option in every execute/spawn call (including
cluster.fork). Add documentation where needed.

fix nodejs#7881

Signed-off-by: Trevor Norris <[email protected]>
  • Loading branch information
indutny authored and trevnorris committed Jul 2, 2014
1 parent 1100f3d commit ae1e325
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doc/api/child_process.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ See also: `child_process.exec()` and `child_process.fork()`
* `timeout` {Number} (Default: 0)
* `maxBuffer` {Number} (Default: `200*1024`)
* `killSignal` {String} (Default: 'SIGTERM')
* `uid` {Number} Sets the user identity of the process. (See setuid(2).)
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
* `callback` {Function} called with the output when process terminates
* `error` {Error}
* `stdout` {Buffer}
Expand Down Expand Up @@ -544,6 +546,8 @@ the child process is killed.
* `timeout` {Number} (Default: 0)
* `maxBuffer` {Number} (Default: 200\*1024)
* `killSignal` {String} (Default: 'SIGTERM')
* `uid` {Number} Sets the user identity of the process. (See setuid(2).)
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
* `callback` {Function} called with the output when process terminates
* `error` {Error}
* `stdout` {Buffer}
Expand All @@ -570,6 +574,8 @@ leaner than `child_process.exec`. It has the same options.
piped to the parent, otherwise they will be inherited from the parent, see
the "pipe" and "inherit" options for `spawn()`'s `stdio` for more details
(default is false)
* `uid` {Number} Sets the user identity of the process. (See setuid(2).)
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
* Return: ChildProcess object

This is a special case of the `spawn()` functionality for spawning Node
Expand Down
2 changes: 2 additions & 0 deletions doc/api/cluster.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ values are `"rr"` and `"none"`.
(Default=`process.argv.slice(2)`)
* `silent` {Boolean} whether or not to send output to parent's stdio.
(Default=`false`)
* `uid` {Number} Sets the user identity of the process. (See setuid(2).)
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)

After calling `.setupMaster()` (or `.fork()`) this settings object will contain
the settings, including the default values.
Expand Down
2 changes: 2 additions & 0 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ exports.execFile = function(file /* args, options, callback */) {
var child = spawn(file, args, {
cwd: options.cwd,
env: options.env,
gid: options.gid,
uid: options.uid,
windowsVerbatimArguments: !!options.windowsVerbatimArguments
});

Expand Down
4 changes: 3 additions & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ function masterInit() {
worker.process = fork(cluster.settings.exec, cluster.settings.args, {
env: workerEnv,
silent: cluster.settings.silent,
execArgv: createWorkerExecArgv(cluster.settings.execArgv, worker)
execArgv: createWorkerExecArgv(cluster.settings.execArgv, worker),
gid: cluster.settings.gid,
uid: cluster.settings.uid
});
worker.process.once('exit', function(exitCode, signalCode) {
worker.suicide = !!worker.suicide;
Expand Down

0 comments on commit ae1e325

Please sign in to comment.