2015-05-19 19:00:06 +08:00
|
|
|
'use strict';
|
2013-08-13 06:01:05 +08:00
|
|
|
// Requires special privileges
|
2016-12-31 07:38:06 +08:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
2010-05-19 08:40:44 +08:00
|
|
|
|
|
|
|
var oldgid = process.getgid();
|
|
|
|
process.setgid('nobody');
|
|
|
|
var newgid = process.getgid();
|
2016-12-30 23:09:13 +08:00
|
|
|
assert.notStrictEqual(newgid, oldgid, 'gids expected to be different');
|
2010-05-19 08:40:44 +08:00
|
|
|
|
|
|
|
var olduid = process.getuid();
|
|
|
|
process.setuid('nobody');
|
|
|
|
var newuid = process.getuid();
|
2016-12-30 23:09:13 +08:00
|
|
|
assert.notStrictEqual(newuid, olduid, 'uids expected to be different');
|
2010-05-19 08:40:44 +08:00
|
|
|
|
|
|
|
try {
|
|
|
|
process.setuid('nobody1234');
|
|
|
|
} catch (e) {
|
2017-01-08 23:36:25 +08:00
|
|
|
assert.strictEqual(e.message,
|
2010-12-06 06:33:52 +08:00
|
|
|
'failed to resolve group',
|
|
|
|
'unexpected error message'
|
2010-05-19 08:40:44 +08:00
|
|
|
);
|
|
|
|
}
|