diff options
author | Divyanshu Singh <dsinecos@gmail.com> | 2018-04-02 22:55:31 +0530 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-04-06 18:52:45 +0200 |
commit | 3dc540410596ff1173586ba1bd9c171196d6f348 (patch) | |
tree | c5aaadc1848a6fc8ce804df7191605af1bac4a1e /test | |
parent | f8b3774d859dd6d210afc6a9b39dc4dd7cb025dd (diff) | |
download | android-node-v8-3dc540410596ff1173586ba1bd9c171196d6f348.tar.gz android-node-v8-3dc540410596ff1173586ba1bd9c171196d6f348.tar.bz2 android-node-v8-3dc540410596ff1173586ba1bd9c171196d6f348.zip |
test: resolve process.setegid error on Ubuntu
When the tests are run as root in Ubuntu, process.setegid is called with
'nobody' as an argument. This throws an error in Ubuntu. This is because
in Ubuntu the equivalent of 'nobody' group is named as 'nogroup'.
This commit sets egid to 'nobody' first and if it throws a `group id
does not exist` error, it attempts to set egid to 'nogroup'. If it still
causes an error, the error is thrown.
PR-URL: https://github.com/nodejs/node/pull/19757
Refs: https://github.com/nodejs/node/issues/19594
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-process-geteuid-getegid.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/parallel/test-process-geteuid-getegid.js b/test/parallel/test-process-geteuid-getegid.js index 41e37874a4..adae58abeb 100644 --- a/test/parallel/test-process-geteuid-getegid.js +++ b/test/parallel/test-process-geteuid-getegid.js @@ -38,7 +38,15 @@ if (process.getuid() !== 0) { // If we are running as super user... const oldgid = process.getegid(); -process.setegid('nobody'); +try { + process.setegid('nobody'); +} catch (err) { + if (err.message !== 'setegid group id does not exist') { + throw err; + } else { + process.setegid('nogroup'); + } +} const newgid = process.getegid(); assert.notStrictEqual(newgid, oldgid); |