Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fc2956d

Browse filesBrowse files
committed
process: backport process/methods file
To ease future backports, create the process/methods file introduced in #19973. This commit just adds the JS functions that forward calls to C++ and does not change type checking. PR-URL: #21172 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent fc0b361 commit fc2956d
Copy full SHA for fc2956d

File tree

Expand file treeCollapse file tree

4 files changed

+67
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+67
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/bootstrap/node.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/node.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
NativeModule.require('internal/process/warning').setup();
4141
NativeModule.require('internal/process/next_tick').setup();
4242
NativeModule.require('internal/process/stdio').setup();
43+
NativeModule.require('internal/process/methods').setup();
4344

4445
const perf = process.binding('performance');
4546
const {
Collapse file

‎lib/internal/process/methods.js‎

Copy file name to clipboard
+65Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
'use strict';
2+
3+
function setupProcessMethods() {
4+
// Non-POSIX platforms like Windows don't have certain methods.
5+
if (process.setgid !== undefined) {
6+
setupPosixMethods();
7+
}
8+
9+
const { chdir: _chdir, umask: _umask } = process;
10+
11+
process.chdir = chdir;
12+
process.umask = umask;
13+
14+
function chdir(...args) {
15+
return _chdir(...args);
16+
}
17+
18+
function umask(...args) {
19+
return _umask(...args);
20+
}
21+
}
22+
23+
function setupPosixMethods() {
24+
const {
25+
initgroups: _initgroups,
26+
setegid: _setegid,
27+
seteuid: _seteuid,
28+
setgid: _setgid,
29+
setuid: _setuid,
30+
setgroups: _setgroups
31+
} = process;
32+
33+
process.initgroups = initgroups;
34+
process.setegid = setegid;
35+
process.seteuid = seteuid;
36+
process.setgid = setgid;
37+
process.setuid = setuid;
38+
process.setgroups = setgroups;
39+
40+
function initgroups(...args) {
41+
return _initgroups(...args);
42+
}
43+
44+
function setegid(...args) {
45+
return _setegid(...args);
46+
}
47+
48+
function seteuid(...args) {
49+
return _seteuid(...args);
50+
}
51+
52+
function setgid(...args) {
53+
return _setgid(...args);
54+
}
55+
56+
function setuid(...args) {
57+
return _setuid(...args);
58+
}
59+
60+
function setgroups(...args) {
61+
return _setgroups(...args);
62+
}
63+
}
64+
65+
exports.setup = setupProcessMethods;
Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
'lib/internal/net.js',
121121
'lib/internal/os.js',
122122
'lib/internal/process/esm_loader.js',
123+
'lib/internal/process/methods.js',
123124
'lib/internal/process/next_tick.js',
124125
'lib/internal/process/promises.js',
125126
'lib/internal/process/stdio.js',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.