| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ff47915 commit 69eaff1
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,16 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const credentials = internalBinding('credentials'); | |
| 4 | + const rawMethods = internalBinding('process_methods'); | ||
| 5 | + // TODO: this should be detached from ERR_WORKER_UNSUPPORTED_OPERATION | ||
| 6 | + const { unavailable } = require('internal/process/worker_thread_only'); | ||
| 4 | 7 | ||
| 5 | - if (credentials.implementsPosixCredentials) { | ||
| 6 | - // TODO: this should be detached from ERR_WORKER_UNSUPPORTED_OPERATION | ||
| 7 | - const { unavailable } = require('internal/process/worker_thread_only'); | ||
| 8 | + process.abort = unavailable('process.abort()'); | ||
| 9 | + process.chdir = unavailable('process.chdir()'); | ||
| 10 | + process.umask = wrappedUmask; | ||
| 11 | + process.cwd = rawMethods.cwd; | ||
| 8 | 12 | ||
| 13 | + if (credentials.implementsPosixCredentials) { | ||
| 9 | 14 | process.initgroups = unavailable('process.initgroups()'); | |
| 10 | 15 | process.setgroups = unavailable('process.setgroups()'); | |
| 11 | 16 | process.setegid = unavailable('process.setegid()'); | |
@@ -16,3 +21,16 @@ if (credentials.implementsPosixCredentials) { | |||
| 16 | 21 | ||
| 17 | 22 | // ---- keep the attachment of the wrappers above so that it's easier to ---- | |
| 18 | 23 | // ---- compare the setups side-by-side ----- | |
| 24 | + | ||
| 25 | + const { | ||
| 26 | + codes: { ERR_WORKER_UNSUPPORTED_OPERATION } | ||
| 27 | + } = require('internal/errors'); | ||
| 28 | + | ||
| 29 | + function 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 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const credentials = internalBinding('credentials'); | |
| 4 | + const rawMethods = internalBinding('process_methods'); | ||
| 5 | + | ||
| 6 | + process.abort = rawMethods.abort; | ||
| 7 | + process.umask = wrappedUmask; | ||
| 8 | + process.chdir = wrappedChdir; | ||
| 9 | + process.cwd = wrappedCwd; | ||
| 4 | 10 | ||
| 5 | 11 | if (credentials.implementsPosixCredentials) { | |
| 6 | 12 | const wrapped = wrapPosixCredentialSetters(credentials); | |
@@ -16,6 +22,11 @@ if (credentials.implementsPosixCredentials) { | |||
| 16 | 22 | // ---- keep the attachment of the wrappers above so that it's easier to ---- | |
| 17 | 23 | // ---- compare the setups side-by-side ----- | |
| 18 | 24 | ||
| 25 | + const { | ||
| 26 | + parseMode, | ||
| 27 | + validateString | ||
| 28 | + } = require('internal/validators'); | ||
| 29 | + | ||
| 19 | 30 | function wrapPosixCredentialSetters(credentials) { | |
| 20 | 31 | const { | |
| 21 | 32 | ArrayIsArray, | |
@@ -94,3 +105,26 @@ function wrapPosixCredentialSetters(credentials) { | |||
| 94 | 105 | setuid: wrapIdSetter('User', _setuid) | |
| 95 | 106 | }; | |
| 96 | 107 | } | |
| 108 | + | ||
| 109 | + // Cache the working directory to prevent lots of lookups. If the working | ||
| 110 | + // directory is changed by `chdir`, it'll be updated. | ||
| 111 | + let cachedCwd = ''; | ||
| 112 | + | ||
| 113 | + function wrappedChdir(directory) { | ||
| 114 | + validateString(directory, 'directory'); | ||
| 115 | + rawMethods.chdir(directory); | ||
| 116 | + // Mark cache that it requires an update. | ||
| 117 | + cachedCwd = ''; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + function wrappedUmask(mask) { | ||
| 121 | + if (mask !== undefined) { | ||
| 122 | + mask = parseMode(mask, 'mask'); | ||
| 123 | + } | ||
| 124 | + return rawMethods.umask(mask); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + function wrappedCwd() { | ||
| 128 | + cachedCwd = rawMethods.cwd(); | ||
| 129 | + return cachedCwd; | ||
| 130 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,6 @@ | |||
| 3 | 3 | const { ObjectDefineProperty } = primordials; | |
| 4 | 4 | const rawMethods = internalBinding('process_methods'); | |
| 5 | 5 | ||
| 6 | - process.abort = rawMethods.abort; | ||
| 7 | - process.umask = wrappedUmask; | ||
| 8 | - process.chdir = wrappedChdir; | ||
| 9 | - process.cwd = wrappedCwd; | ||
| 10 | - | ||
| 11 | 6 | // TODO(joyeecheung): deprecate and remove these underscore methods | |
| 12 | 7 | process._debugProcess = rawMethods._debugProcess; | |
| 13 | 8 | process._debugEnd = rawMethods._debugEnd; | |
@@ -38,33 +33,6 @@ process.on('removeListener', stopListeningIfSignal); | |||
| 38 | 33 | // ---- compare the setups side-by-side ----- | |
| 39 | 34 | ||
| 40 | 35 | const { guessHandleType } = internalBinding('util'); | |
| 41 | - const { | ||
| 42 | - parseMode, | ||
| 43 | - validateString | ||
| 44 | - } = require('internal/validators'); | ||
| 45 | - | ||
| 46 | - // Cache the working directory to prevent lots of lookups. If the working | ||
| 47 | - // directory is changed by `chdir`, it'll be updated. | ||
| 48 | - let cachedCwd = ''; | ||
| 49 | - | ||
| 50 | - function wrappedChdir(directory) { | ||
| 51 | - validateString(directory, 'directory'); | ||
| 52 | - rawMethods.chdir(directory); | ||
| 53 | - // Mark cache that it requires an update. | ||
| 54 | - cachedCwd = ''; | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - function wrappedUmask(mask) { | ||
| 58 | - if (mask !== undefined) { | ||
| 59 | - mask = parseMode(mask, 'mask'); | ||
| 60 | - } | ||
| 61 | - return rawMethods.umask(mask); | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - function wrappedCwd() { | ||
| 65 | - cachedCwd = rawMethods.cwd(); | ||
| 66 | - return cachedCwd; | ||
| 67 | - } | ||
| 68 | 36 | ||
| 69 | 37 | function createWritableStdioStream(fd) { | |
| 70 | 38 | let stream; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,15 +1,6 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { ObjectDefineProperty } = primordials; | |
| 4 | - const rawMethods = internalBinding('process_methods'); | ||
| 5 | - const { | ||
| 6 | - unavailable | ||
| 7 | - } = require('internal/process/worker_thread_only'); | ||
| 8 | - | ||
| 9 | - process.abort = unavailable('process.abort()'); | ||
| 10 | - process.chdir = unavailable('process.chdir()'); | ||
| 11 | - process.umask = wrappedUmask; | ||
| 12 | - process.cwd = rawMethods.cwd; | ||
| 13 | 4 | ||
| 14 | 5 | delete process._debugProcess; | |
| 15 | 6 | delete process._debugEnd; | |
@@ -42,9 +33,6 @@ process.removeListener('removeListener', stopListeningIfSignal); | |||
| 42 | 33 | const { | |
| 43 | 34 | createWorkerStdio | |
| 44 | 35 | } = require('internal/worker/io'); | |
| 45 | - const { | ||
| 46 | - codes: { ERR_WORKER_UNSUPPORTED_OPERATION } | ||
| 47 | - } = require('internal/errors'); | ||
| 48 | 36 | ||
| 49 | 37 | let workerStdio; | |
| 50 | 38 | function lazyWorkerStdio() { | |
@@ -57,12 +45,3 @@ function getStdout() { return lazyWorkerStdio().stdout; } | |||
| 57 | 45 | function getStderr() { return lazyWorkerStdio().stderr; } | |
| 58 | 46 | ||
| 59 | 47 | function getStdin() { return lazyWorkerStdio().stdin; } | |
| 60 | - | ||
| 61 | - function wrappedUmask(mask) { | ||
| 62 | - // process.umask() is a read-only operation in workers. | ||
| 63 | - if (mask !== undefined) { | ||
| 64 | - throw new ERR_WORKER_UNSUPPORTED_OPERATION('Setting process.umask()'); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - return rawMethods.umask(mask); | ||
| 68 | - } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments