test: use .code for error in setgid

When the 'nobody' user is missing use .code to detect this, its more
robust than than the .message string.

Refs: https://github.com/nodejs/node/issues/19594

PR-URL: https://github.com/nodejs/node/pull/28219
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
This commit is contained in:
= 2019-06-13 17:14:33 -07:00 committed by Rich Trott
parent b0f75818f3
commit e57bf47351

View File

@ -74,7 +74,7 @@ const oldgid = process.getgid();
try {
process.setgid('nobody');
} catch (err) {
if (err.message !== 'setgid group id does not exist') {
if (err.code !== 'ERR_UNKNOWN_CREDENTIAL') {
throw err;
}
process.setgid('nogroup');