blob: 8dab52389b038416ec983571e7d0b22b09058b26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
'use strict';
const common = require('../common');
const assert = require('assert');
if (common.isWindows) {
assert.strictEqual(process.geteuid, undefined);
assert.strictEqual(process.getegid, undefined);
assert.strictEqual(process.seteuid, undefined);
assert.strictEqual(process.setegid, undefined);
return;
}
assert.throws(() => {
process.seteuid({});
}, /^TypeError: seteuid argument must be a number or string$/);
assert.throws(() => {
process.seteuid('fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf');
}, /^Error: seteuid user id does not exist$/);
// If we're not running as super user...
if (process.getuid() !== 0) {
assert.doesNotThrow(() => {
process.getegid();
process.geteuid();
});
assert.throws(() => {
process.setegid('nobody');
}, /^Error: (?:EPERM, .+|setegid group id does not exist)$/);
assert.throws(() => {
process.seteuid('nobody');
}, /^Error: (?:EPERM, .+|seteuid user id does not exist)$/);
return;
}
// If we are running as super user...
const oldgid = process.getegid();
process.setegid('nobody');
const newgid = process.getegid();
assert.notStrictEqual(newgid, oldgid);
const olduid = process.geteuid();
process.seteuid('nobody');
const newuid = process.geteuid();
assert.notStrictEqual(newuid, olduid);
|