diff options
author | Divyanshu Singh <dsinecos@gmail.com> | 2018-04-02 22:10:01 +0530 |
---|---|---|
committer | Luigi Pinca <luigipinca@gmail.com> | 2018-04-21 10:19:34 +0200 |
commit | cc8a33edbc91d5c7c2cadd8f51805b3937f25ead (patch) | |
tree | a263f9c0b882009a22485d0271a9854f6b7a200d /test/parallel/test-process-uid-gid.js | |
parent | 2a88f02f2ff861b794ea9b83bbdfe71950d584ed (diff) | |
download | android-node-v8-cc8a33edbc91d5c7c2cadd8f51805b3937f25ead.tar.gz android-node-v8-cc8a33edbc91d5c7c2cadd8f51805b3937f25ead.tar.bz2 android-node-v8-cc8a33edbc91d5c7c2cadd8f51805b3937f25ead.zip |
test: resolve process.setgid() error on Ubuntu
When the tests are run as root in Ubuntu, process.setgid() is called
with 'nobody' as an argument. This throws an error in Ubuntu and is
because, in Ubuntu, the equivalent of 'nobody' group is named as
'nogroup'.
This commit sets gid to 'nobody' first and if it throws a "group id
does not exist" error, it attempts to set gid to 'nogroup'. If it still
causes an error, the error is thrown.
PR-URL: https://github.com/nodejs/node/pull/19755
Refs: https://github.com/nodejs/node/issues/19594
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test/parallel/test-process-uid-gid.js')
-rw-r--r-- | test/parallel/test-process-uid-gid.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test/parallel/test-process-uid-gid.js b/test/parallel/test-process-uid-gid.js index d3aac29dec..d044c45a32 100644 --- a/test/parallel/test-process-uid-gid.js +++ b/test/parallel/test-process-uid-gid.js @@ -61,7 +61,14 @@ if (process.getuid() !== 0) { // If we are running as super user... const oldgid = process.getgid(); -process.setgid('nobody'); +try { + process.setgid('nobody'); +} catch (err) { + if (err.message !== 'setgid group id does not exist') { + throw err; + } + process.setgid('nogroup'); +} const newgid = process.getgid(); assert.notStrictEqual(newgid, oldgid); |