Skip to content

Commit b4e86f1

Browse files
dsinecosjasnell
authored andcommitted
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: #19755 Refs: #19594 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 18f41dd commit b4e86f1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/parallel/test-process-uid-gid.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,14 @@ if (process.getuid() !== 0) {
6161

6262
// If we are running as super user...
6363
const oldgid = process.getgid();
64-
process.setgid('nobody');
64+
try {
65+
process.setgid('nobody');
66+
} catch (err) {
67+
if (err.message !== 'setgid group id does not exist') {
68+
throw err;
69+
}
70+
process.setgid('nogroup');
71+
}
6572
const newgid = process.getgid();
6673
assert.notStrictEqual(newgid, oldgid);
6774

0 commit comments

Comments
 (0)