mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 15:41:06 +00:00
src: fix external module env and kDisableNodeOptionsEnv
PR-URL: https://github.com/nodejs/node/pull/52905 Fixes: https://github.com/nodejs/node/issues/51227 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
parent
98a1ecfc7b
commit
b9ad94b6da
@ -2870,6 +2870,13 @@ equivalent to using the `--redirect-warnings=file` command-line flag.
|
|||||||
added:
|
added:
|
||||||
- v13.0.0
|
- v13.0.0
|
||||||
- v12.16.0
|
- v12.16.0
|
||||||
|
changes:
|
||||||
|
- version:
|
||||||
|
- REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/52905
|
||||||
|
description:
|
||||||
|
Remove the possibility to use this env var with
|
||||||
|
kDisableNodeOptionsEnv for embedders.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Path to a Node.js module which will be loaded in place of the built-in REPL.
|
Path to a Node.js module which will be loaded in place of the built-in REPL.
|
||||||
|
@ -872,6 +872,15 @@ static ExitCode InitializeNodeWithArgsInternal(
|
|||||||
&env_argv, nullptr, errors, kAllowedInEnvvar);
|
&env_argv, nullptr, errors, kAllowedInEnvvar);
|
||||||
if (exit_code != ExitCode::kNoFailure) return exit_code;
|
if (exit_code != ExitCode::kNoFailure) return exit_code;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
std::string node_repl_external_env = {};
|
||||||
|
if (credentials::SafeGetenv("NODE_REPL_EXTERNAL_MODULE",
|
||||||
|
&node_repl_external_env) ||
|
||||||
|
!node_repl_external_env.empty()) {
|
||||||
|
errors->emplace_back("NODE_REPL_EXTERNAL_MODULE can't be used with "
|
||||||
|
"kDisableNodeOptionsEnv");
|
||||||
|
return ExitCode::kInvalidCommandLineArgument;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -35,8 +35,15 @@ NODE_MAIN(int argc, node::argv_type raw_argv[]) {
|
|||||||
std::shared_ptr<node::InitializationResult> result =
|
std::shared_ptr<node::InitializationResult> result =
|
||||||
node::InitializeOncePerProcess(
|
node::InitializeOncePerProcess(
|
||||||
args,
|
args,
|
||||||
{node::ProcessInitializationFlags::kNoInitializeV8,
|
{
|
||||||
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform});
|
node::ProcessInitializationFlags::kNoInitializeV8,
|
||||||
|
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform,
|
||||||
|
// This is used to test NODE_REPL_EXTERNAL_MODULE is disabled with
|
||||||
|
// kDisableNodeOptionsEnv. If other tests need NODE_OPTIONS
|
||||||
|
// support in the future, split this configuration out as a
|
||||||
|
// command line option.
|
||||||
|
node::ProcessInitializationFlags::kDisableNodeOptionsEnv,
|
||||||
|
});
|
||||||
|
|
||||||
for (const std::string& error : result->errors())
|
for (const std::string& error : result->errors())
|
||||||
fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str());
|
fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str());
|
||||||
|
@ -151,3 +151,21 @@ for (const extraSnapshotArgs of [
|
|||||||
[ '--', ...runEmbeddedArgs ],
|
[ '--', ...runEmbeddedArgs ],
|
||||||
{ cwd: tmpdir.path });
|
{ cwd: tmpdir.path });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Guarantee NODE_REPL_EXTERNAL_MODULE won't bypass kDisableNodeOptionsEnv
|
||||||
|
{
|
||||||
|
spawnSyncAndExit(
|
||||||
|
binary,
|
||||||
|
['require("os")'],
|
||||||
|
{
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
'NODE_REPL_EXTERNAL_MODULE': 'fs',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: 9,
|
||||||
|
signal: null,
|
||||||
|
stderr: `${binary}: NODE_REPL_EXTERNAL_MODULE can't be used with kDisableNodeOptionsEnv\n`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user