src: register the --allow-fs-vfs permission flag · nodejs/node@207aae4 · GitHub
Skip to content

Commit 207aae4

Browse files
committed
src: register the --allow-fs-vfs permission flag
Mounting a VFS under the permission model is refused with a message telling the user to pass --allow-fs-vfs, but that option was never registered, so `node --allow-fs-vfs` failed with "bad option" and a virtual file system could not be mounted under --permission at all. Register it alongside the other permission flags and document it. Signed-off-by: Philipp Dunkel <pip@pipobscure.com>
1 parent 19b0f03 commit 207aae4

5 files changed

Lines changed: 81 additions & 0 deletions

File tree

‎doc/api/cli.md‎

Lines changed: 23 additions & 0 deletions

‎doc/node.1‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ process.permission.has('fs.read', 'custom-require.js'); // true
166166
process.permission.has('fs.read', 'custom-require-2.js'); // true
167167
.Ed
168168
.
169+
.It Fl -allow-fs-vfs
170+
When using the Permission Model, a virtual file system cannot be
171+
mounted by default: \fBvfs.mount()\fR throws \fBERR_INVALID_STATE\fR unless the
172+
user explicitly passes the \fB--allow-fs-vfs\fR flag when starting Node.js.
173+
A mounted VFS serves paths that the file system permissions do not describe,
174+
so mounting one is gated on its own flag rather than on \fB--allow-fs-read\fR or
175+
\fB--allow-fs-write\fR.
176+
.Bd -literal
177+
$ node --experimental-vfs --permission --allow-fs-vfs app.js
178+
.Ed
179+
.
169180
.It Fl -allow-fs-write
170181
This flag configures file system write permissions using
171182
the Permission Model.
@@ -1944,6 +1955,8 @@ one is included in the list below.
19441955
.It
19451956
\fB--allow-fs-read\fR
19461957
.It
1958+
\fB--allow-fs-vfs\fR
1959+
.It
19471960
\fB--allow-fs-write\fR
19481961
.It
19491962
\fB--allow-inspector\fR

‎src/node_options.cc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,12 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
687687
&EnvironmentOptions::allow_fs_write,
688688
kAllowedInEnvvar,
689689
OptionNamespaces::kPermissionNamespace);
690+
AddOption("--allow-fs-vfs",
691+
"allow mounting a virtual file system when any permissions are set",
692+
BOOL_FIELD(allow_fs_vfs),
693+
kAllowedInEnvvar,
694+
false,
695+
OptionNamespaces::kPermissionNamespace);
690696
AddOption("--allow-addons",
691697
"allow use of addons when any permissions are set",
692698
BOOL_FIELD(allow_addons),

‎src/node_options.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ class EnvironmentOptions : public Options {
219219
DEFINE_BOOL_FIELD(permission) = false;
220220
DEFINE_BOOL_FIELD(permission_audit) = false;
221221
DEFINE_BOOL_FIELD(allow_addons) = false;
222+
DEFINE_BOOL_FIELD(allow_fs_vfs) = false;
222223
DEFINE_BOOL_FIELD(allow_inspector) = false;
223224
DEFINE_BOOL_FIELD(allow_child_process) = false;
224225
DEFINE_BOOL_FIELD(allow_net) = false;

‎test/parallel/test-permission-dlopen-binary.js‎

Lines changed: 38 additions & 0 deletions

0 commit comments

Comments
 (0)