Skip to content

Commit 3dc5404

Browse files
dsinecosaddaleax
authored andcommitted
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: #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>
1 parent f8b3774 commit 3dc5404

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/parallel/test-process-geteuid-getegid.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ if (process.getuid() !== 0) {
3838

3939
// If we are running as super user...
4040
const oldgid = process.getegid();
41-
process.setegid('nobody');
41+
try {
42+
process.setegid('nobody');
43+
} catch (err) {
44+
if (err.message !== 'setegid group id does not exist') {
45+
throw err;
46+
} else {
47+
process.setegid('nogroup');
48+
}
49+
}
4250
const newgid = process.getegid();
4351
assert.notStrictEqual(newgid, oldgid);
4452

0 commit comments

Comments
 (0)