Skip to content

Commit ae1e325

Browse files
indutnytrevnorris
authored andcommitted
child_process: accept uid/gid everywhere
Accept uid/gid option in every execute/spawn call (including cluster.fork). Add documentation where needed. fix #7881 Signed-off-by: Trevor Norris <trev.norris@gmail.com>
1 parent 1100f3d commit ae1e325

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

doc/api/child_process.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ See also: `child_process.exec()` and `child_process.fork()`
491491
* `timeout` {Number} (Default: 0)
492492
* `maxBuffer` {Number} (Default: `200*1024`)
493493
* `killSignal` {String} (Default: 'SIGTERM')
494+
* `uid` {Number} Sets the user identity of the process. (See setuid(2).)
495+
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
494496
* `callback` {Function} called with the output when process terminates
495497
* `error` {Error}
496498
* `stdout` {Buffer}
@@ -544,6 +546,8 @@ the child process is killed.
544546
* `timeout` {Number} (Default: 0)
545547
* `maxBuffer` {Number} (Default: 200\*1024)
546548
* `killSignal` {String} (Default: 'SIGTERM')
549+
* `uid` {Number} Sets the user identity of the process. (See setuid(2).)
550+
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
547551
* `callback` {Function} called with the output when process terminates
548552
* `error` {Error}
549553
* `stdout` {Buffer}
@@ -570,6 +574,8 @@ leaner than `child_process.exec`. It has the same options.
570574
piped to the parent, otherwise they will be inherited from the parent, see
571575
the "pipe" and "inherit" options for `spawn()`'s `stdio` for more details
572576
(default is false)
577+
* `uid` {Number} Sets the user identity of the process. (See setuid(2).)
578+
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
573579
* Return: ChildProcess object
574580

575581
This is a special case of the `spawn()` functionality for spawning Node

doc/api/cluster.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ values are `"rr"` and `"none"`.
128128
(Default=`process.argv.slice(2)`)
129129
* `silent` {Boolean} whether or not to send output to parent's stdio.
130130
(Default=`false`)
131+
* `uid` {Number} Sets the user identity of the process. (See setuid(2).)
132+
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
131133

132134
After calling `.setupMaster()` (or `.fork()`) this settings object will contain
133135
the settings, including the default values.

lib/child_process.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,8 @@ exports.execFile = function(file /* args, options, callback */) {
669669
var child = spawn(file, args, {
670670
cwd: options.cwd,
671671
env: options.env,
672+
gid: options.gid,
673+
uid: options.uid,
672674
windowsVerbatimArguments: !!options.windowsVerbatimArguments
673675
});
674676

lib/cluster.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ function masterInit() {
285285
worker.process = fork(cluster.settings.exec, cluster.settings.args, {
286286
env: workerEnv,
287287
silent: cluster.settings.silent,
288-
execArgv: createWorkerExecArgv(cluster.settings.execArgv, worker)
288+
execArgv: createWorkerExecArgv(cluster.settings.execArgv, worker),
289+
gid: cluster.settings.gid,
290+
uid: cluster.settings.uid
289291
});
290292
worker.process.once('exit', function(exitCode, signalCode) {
291293
worker.suicide = !!worker.suicide;

0 commit comments

Comments
 (0)