Skip to content

Commit

Permalink
test: resolve process.setegid error on Ubuntu
Browse files Browse the repository at this point in the history
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: #19757
Refs: #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>
  • Loading branch information
dsinecos authored and lpinca committed Apr 6, 2018
1 parent 1fcf480 commit 4ae53af
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/parallel/test-process-geteuid-getegid.js
Expand Up @@ -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);

Expand Down

0 comments on commit 4ae53af

Please sign in to comment.