1'use strict'; 2 3const credentials = internalBinding('credentials'); 4const rawMethods = internalBinding('process_methods'); 5// TODO: this should be detached from ERR_WORKER_UNSUPPORTED_OPERATION 6const { unavailable } = require('internal/process/worker_thread_only'); 7 8process.abort = unavailable('process.abort()'); 9process.chdir = unavailable('process.chdir()'); 10process.umask = wrappedUmask; 11process.cwd = rawMethods.cwd; 12 13if (credentials.implementsPosixCredentials) { 14 process.initgroups = unavailable('process.initgroups()'); 15 process.setgroups = unavailable('process.setgroups()'); 16 process.setegid = unavailable('process.setegid()'); 17 process.seteuid = unavailable('process.seteuid()'); 18 process.setgid = unavailable('process.setgid()'); 19 process.setuid = unavailable('process.setuid()'); 20} 21 22// ---- keep the attachment of the wrappers above so that it's easier to ---- 23// ---- compare the setups side-by-side ----- 24 25const { 26 codes: { ERR_WORKER_UNSUPPORTED_OPERATION } 27} = require('internal/errors'); 28 29function wrappedUmask(mask) { 30 // process.umask() is a read-only operation in workers. 31 if (mask !== undefined) { 32 throw new ERR_WORKER_UNSUPPORTED_OPERATION('Setting process.umask()'); 33 } 34 35 return rawMethods.umask(mask); 36} 37