From 90e12f29459555e9b2dd2013e5de4efda6c4b7fb Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Sat, 11 Jan 2025 18:11:16 -0300 Subject: [PATCH] test: clarify fork inherit permission flags This commit updates the documentation and includes a test to ensure that permission model flags will be passed to the child process if `fork` is called PR-URL: https://github.com/nodejs/node/pull/56523 Reviewed-By: Marco Ippolito Reviewed-By: James M Snell --- doc/api/cli.md | 13 ++++++------- .../test-permission-allow-child-process-cli.js | 10 +++++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 10e95dc69945cb..a5a3d10459316c 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -174,19 +174,18 @@ node:internal/child_process:388 ^ Error: Access to this API has been restricted at ChildProcess.spawn (node:internal/child_process:388:28) - at Object.spawn (node:child_process:723:9) - at Object. (/home/index.js:3:14) - at Module._compile (node:internal/modules/cjs/loader:1120:14) - at Module._extensions..js (node:internal/modules/cjs/loader:1174:10) - at Module.load (node:internal/modules/cjs/loader:998:32) - at Module._load (node:internal/modules/cjs/loader:839:12) - at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47 { code: 'ERR_ACCESS_DENIED', permission: 'ChildProcess' } ``` +Unlike `child_process.spawn`, the `child_process.fork` API copies the execution +arguments from the parent process. This means that if you start Node.js with the +Permission Model enabled and include the `--allow-child-process` flag, calling +`child_process.fork()` will propagate all Permission Model flags to the child +process. + ### `--allow-fs-read`