From 3dc540410596ff1173586ba1bd9c171196d6f348 Mon Sep 17 00:00:00 2001 From: Divyanshu Singh Date: Mon, 2 Apr 2018 22:55:31 +0530 Subject: [PATCH] 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 Reviewed-By: Daniel Bevenius Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell --- test/parallel/test-process-geteuid-getegid.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-process-geteuid-getegid.js b/test/parallel/test-process-geteuid-getegid.js index 41e37874a41..adae58abebd 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);