mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 21:35:34 +00:00

This commit lets the uid and gid options of spawn() to be tested independently of one another based on the user's uid and gid. Fixes: https://github.com/nodejs/node/issues/10646 PR-URL: https://github.com/nodejs/node/pull/10647 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
18 lines
508 B
JavaScript
18 lines
508 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const spawn = require('child_process').spawn;
|
|
const expectedError = common.isWindows ? /\bENOTSUP\b/ : /\bEPERM\b/;
|
|
|
|
if (common.isWindows || process.getuid() !== 0) {
|
|
assert.throws(() => {
|
|
spawn('echo', ['fhqwhgads'], {uid: 0});
|
|
}, expectedError);
|
|
}
|
|
|
|
if (common.isWindows || !process.getgroups().some((gid) => gid === 0)) {
|
|
assert.throws(() => {
|
|
spawn('echo', ['fhqwhgads'], {gid: 0});
|
|
}, expectedError);
|
|
}
|