diff options
Diffstat (limited to 'lib/internal/bootstrap/node.js')
-rw-r--r-- | lib/internal/bootstrap/node.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 35565769d21..33d79689d09 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -23,8 +23,7 @@ const { _setupPromises, _chdir, _cpuUsage, _hrtime, _hrtimeBigInt, _memoryUsage, _rawDebug, - _umask, _initgroups, _setegid, _seteuid, - _setgid, _setuid, _setgroups, + _umask, _shouldAbortOnUncaughtToggle } = bootstrappers; const { internalBinding, NativeModule } = loaderExports; @@ -72,13 +71,28 @@ function startup() { NativeModule.require('internal/process/warning').setup(); NativeModule.require('internal/process/next_tick').setup(_setupNextTick, _setupPromises); + const credentials = internalBinding('credentials'); + if (credentials.implementsPosixCredentials) { + process.getuid = credentials.getuid; + process.geteuid = credentials.geteuid; + process.getgid = credentials.getgid; + process.getegid = credentials.getegid; + process.getgroups = credentials.getgroups; + + if (isMainThread) { + const wrapped = mainThreadSetup.wrapPosixCredentialSetters(credentials); + process.initgroups = wrapped.initgroups; + process.setgroups = wrapped.setgroups; + process.setegid = wrapped.setegid; + process.seteuid = wrapped.seteuid; + process.setgid = wrapped.setgid; + process.setuid = wrapped.setuid; + } + } if (isMainThread) { mainThreadSetup.setupStdio(); - mainThreadSetup.setupProcessMethods( - _chdir, _umask, _initgroups, _setegid, _seteuid, - _setgid, _setuid, _setgroups - ); + mainThreadSetup.setupProcessMethods(_chdir, _umask); } else { workerThreadSetup.setupStdio(); } |