-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: refactor bootstrap to use bootstrap object
PR-URL: #20917 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Backport-PR-URL: #21172
- Loading branch information
Showing
9 changed files
with
244 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,49 @@ | ||
'use strict'; | ||
|
||
function setupProcessMethods() { | ||
function setupProcessMethods(_chdir, _cpuUsage, _hrtime, _memoryUsage, | ||
_rawDebug, _umask, _initgroups, _setegid, | ||
_seteuid, _setgid, _setuid, _setgroups) { | ||
// Non-POSIX platforms like Windows don't have certain methods. | ||
if (process.setgid !== undefined) { | ||
setupPosixMethods(); | ||
if (_setgid !== undefined) { | ||
setupPosixMethods(_initgroups, _setegid, _seteuid, | ||
_setgid, _setuid, _setgroups); | ||
} | ||
|
||
const { chdir: _chdir, umask: _umask } = process; | ||
|
||
process.chdir = chdir; | ||
process.umask = umask; | ||
|
||
function chdir(...args) { | ||
process.chdir = function chdir(...args) { | ||
return _chdir(...args); | ||
} | ||
}; | ||
|
||
function umask(...args) { | ||
process.umask = function umask(...args) { | ||
return _umask(...args); | ||
} | ||
}; | ||
} | ||
|
||
function setupPosixMethods() { | ||
const { | ||
initgroups: _initgroups, | ||
setegid: _setegid, | ||
seteuid: _seteuid, | ||
setgid: _setgid, | ||
setuid: _setuid, | ||
setgroups: _setgroups | ||
} = process; | ||
|
||
process.initgroups = initgroups; | ||
process.setegid = setegid; | ||
process.seteuid = seteuid; | ||
process.setgid = setgid; | ||
process.setuid = setuid; | ||
process.setgroups = setgroups; | ||
function setupPosixMethods(_initgroups, _setegid, _seteuid, | ||
_setgid, _setuid, _setgroups) { | ||
|
||
function initgroups(...args) { | ||
process.initgroups = function initgroups(...args) { | ||
return _initgroups(...args); | ||
} | ||
}; | ||
|
||
function setegid(...args) { | ||
process.setegid = function setegid(...args) { | ||
return _setegid(...args); | ||
} | ||
}; | ||
|
||
function seteuid(...args) { | ||
process.seteuid = function seteuid(...args) { | ||
return _seteuid(...args); | ||
} | ||
}; | ||
|
||
function setgid(...args) { | ||
process.setgid = function setgid(...args) { | ||
return _setgid(...args); | ||
} | ||
}; | ||
|
||
function setuid(...args) { | ||
process.setuid = function setuid(...args) { | ||
return _setuid(...args); | ||
} | ||
}; | ||
|
||
function setgroups(...args) { | ||
process.setgroups = function setgroups(...args) { | ||
return _setgroups(...args); | ||
} | ||
}; | ||
} | ||
|
||
exports.setup = setupProcessMethods; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.