Skip to content

Commit 5fd03e6

Browse files
RafaelGSSrichardlau
authored andcommitted
child_process: propagate config-file permission flags to children
Signed-off-by: RafaelGSS <[email protected]> PR-URL: #66559 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Ulises Gascón <[email protected]>
1 parent fc3b067 commit 5fd03e6

4 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎lib/child_process.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,11 @@ function copyPermissionModelFlagsToEnv(env, key, args) {
574574
}
575575

576576
const flagsToCopy = getPermissionModelFlagsToCopy();
577+
const copiedFlags = new SafeSet();
577578
for (const arg of process.execArgv) {
578579
for (const flag of flagsToCopy) {
579580
if (arg.startsWith(flag)) {
581+
copiedFlags.add(flag);
580582
env[key] = `${env[key] ? env[key] + ' ' + arg : arg}`;
581583
}
582584
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const { spawnSync } = require('child_process');
2+
const { status, stdout, stderr } = spawnSync(process.execPath, [
3+
'-p',
4+
`JSON.stringify([
5+
typeof process.permission,
6+
process.permission.has("fs.read"),
7+
process.permission.has("fs.write"),
8+
process.permission.has("child"),
9+
process.permission.has("worker"),
10+
])`,
11+
]);
12+
console.log(JSON.stringify({
13+
status,
14+
stdout: stdout.toString().trim(),
15+
stderr: stderr.toString(),
16+
}));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permission": {
3+
"allow-child-process": true,
4+
"allow-worker": true,
5+
"allow-fs-read": [
6+
"*"
7+
]
8+
}
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"permission": {
3+
"permission": true,
4+
"allow-child-process": true,
5+
"allow-worker": true,
6+
"allow-fs-read": [
7+
"*",
8+
"/nonexistent/dir with \"quotes\" and \\backslash"
9+
]
10+
}
11+
}

0 commit comments

Comments
 (0)