mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 03:13:13 +00:00

Whether these APIs should be available for Node.js instances semantically depends on whether the current Node.js instance was assigned ownership of process-wide state, and not whether it refers to the main thread or not. PR-URL: https://github.com/nodejs/node/pull/31172 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const credentials = internalBinding('credentials');
|
|
const rawMethods = internalBinding('process_methods');
|
|
// TODO: this should be detached from ERR_WORKER_UNSUPPORTED_OPERATION
|
|
const { unavailable } = require('internal/process/worker_thread_only');
|
|
|
|
process.abort = unavailable('process.abort()');
|
|
process.chdir = unavailable('process.chdir()');
|
|
process.umask = wrappedUmask;
|
|
process.cwd = rawMethods.cwd;
|
|
|
|
if (credentials.implementsPosixCredentials) {
|
|
process.initgroups = unavailable('process.initgroups()');
|
|
process.setgroups = unavailable('process.setgroups()');
|
|
process.setegid = unavailable('process.setegid()');
|
|
process.seteuid = unavailable('process.seteuid()');
|
|
process.setgid = unavailable('process.setgid()');
|
|
process.setuid = unavailable('process.setuid()');
|
|
}
|
|
|
|
// ---- keep the attachment of the wrappers above so that it's easier to ----
|
|
// ---- compare the setups side-by-side -----
|
|
|
|
const {
|
|
codes: { ERR_WORKER_UNSUPPORTED_OPERATION }
|
|
} = require('internal/errors');
|
|
|
|
function wrappedUmask(mask) {
|
|
// process.umask() is a read-only operation in workers.
|
|
if (mask !== undefined) {
|
|
throw new ERR_WORKER_UNSUPPORTED_OPERATION('Setting process.umask()');
|
|
}
|
|
|
|
return rawMethods.umask(mask);
|
|
}
|