src: add buildflag to force context-aware addons
PR-URL: https://github.com/nodejs/node/pull/29631 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
5058c7f138
commit
3c17f160e3
@ -411,6 +411,13 @@ added: v6.0.0
|
|||||||
|
|
||||||
Silence all process warnings (including deprecations).
|
Silence all process warnings (including deprecations).
|
||||||
|
|
||||||
|
### `--force-context-aware`
|
||||||
|
<!-- YAML
|
||||||
|
added: REPLACEME
|
||||||
|
-->
|
||||||
|
|
||||||
|
Disable loading non-context-aware native addons.
|
||||||
|
|
||||||
### `--openssl-config=file`
|
### `--openssl-config=file`
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v6.9.0
|
added: v6.9.0
|
||||||
@ -980,6 +987,7 @@ Node.js options that are allowed are:
|
|||||||
* `--experimental-report`
|
* `--experimental-report`
|
||||||
* `--experimental-vm-modules`
|
* `--experimental-vm-modules`
|
||||||
* `--experimental-wasm-modules`
|
* `--experimental-wasm-modules`
|
||||||
|
* `--force-context-aware`
|
||||||
* `--force-fips`
|
* `--force-fips`
|
||||||
* `--frozen-intrinsics`
|
* `--frozen-intrinsics`
|
||||||
* `--heapsnapshot-signal`
|
* `--heapsnapshot-signal`
|
||||||
|
@ -1611,6 +1611,11 @@ OpenSSL crypto support.
|
|||||||
An attempt was made to use features that require [ICU][], but Node.js was not
|
An attempt was made to use features that require [ICU][], but Node.js was not
|
||||||
compiled with ICU support.
|
compiled with ICU support.
|
||||||
|
|
||||||
|
<a id="ERR_NON_CONTEXT_AWARE_DISABLED"></a>
|
||||||
|
### ERR_NON_CONTEXT_AWARE_DISABLED
|
||||||
|
|
||||||
|
A non-context-aware native addon was loaded in a process that disallows them.
|
||||||
|
|
||||||
<a id="ERR_OUT_OF_RANGE"></a>
|
<a id="ERR_OUT_OF_RANGE"></a>
|
||||||
### ERR_OUT_OF_RANGE
|
### ERR_OUT_OF_RANGE
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "node_binding.h"
|
#include "node_binding.h"
|
||||||
|
#include "node_errors.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include "env-inl.h"
|
#include "env-inl.h"
|
||||||
#include "node_native_module_env.h"
|
#include "node_native_module_env.h"
|
||||||
@ -462,6 +463,13 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mp != nullptr) {
|
if (mp != nullptr) {
|
||||||
|
if (mp->nm_context_register_func == nullptr) {
|
||||||
|
if (env->options()->force_context_aware) {
|
||||||
|
dlib->Close();
|
||||||
|
THROW_ERR_NON_CONTEXT_AWARE_DISABLED(env);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
mp->nm_dso_handle = dlib->handle_;
|
mp->nm_dso_handle = dlib->handle_;
|
||||||
dlib->SaveInGlobalHandleMap(mp);
|
dlib->SaveInGlobalHandleMap(mp);
|
||||||
} else {
|
} else {
|
||||||
|
@ -52,6 +52,7 @@ void PrintErrorString(const char* format, ...);
|
|||||||
V(ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST, TypeError) \
|
V(ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST, TypeError) \
|
||||||
V(ERR_MISSING_PASSPHRASE, TypeError) \
|
V(ERR_MISSING_PASSPHRASE, TypeError) \
|
||||||
V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \
|
V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \
|
||||||
|
V(ERR_NON_CONTEXT_AWARE_DISABLED, Error) \
|
||||||
V(ERR_MODULE_NOT_FOUND, Error) \
|
V(ERR_MODULE_NOT_FOUND, Error) \
|
||||||
V(ERR_OUT_OF_RANGE, RangeError) \
|
V(ERR_OUT_OF_RANGE, RangeError) \
|
||||||
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \
|
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \
|
||||||
@ -96,6 +97,8 @@ void PrintErrorString(const char* format, ...);
|
|||||||
V(ERR_MISSING_PLATFORM_FOR_WORKER, \
|
V(ERR_MISSING_PLATFORM_FOR_WORKER, \
|
||||||
"The V8 platform used by this instance of Node does not support " \
|
"The V8 platform used by this instance of Node does not support " \
|
||||||
"creating Workers") \
|
"creating Workers") \
|
||||||
|
V(ERR_NON_CONTEXT_AWARE_DISABLED, \
|
||||||
|
"Loading non context-aware native modules has been disabled") \
|
||||||
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, \
|
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, \
|
||||||
"Script execution was interrupted by `SIGINT`") \
|
"Script execution was interrupted by `SIGINT`") \
|
||||||
V(ERR_TRANSFERRING_EXTERNALIZED_SHAREDARRAYBUFFER, \
|
V(ERR_TRANSFERRING_EXTERNALIZED_SHAREDARRAYBUFFER, \
|
||||||
|
@ -385,6 +385,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
|
|||||||
"silence all process warnings",
|
"silence all process warnings",
|
||||||
&EnvironmentOptions::no_warnings,
|
&EnvironmentOptions::no_warnings,
|
||||||
kAllowedInEnvironment);
|
kAllowedInEnvironment);
|
||||||
|
AddOption("--force-context-aware",
|
||||||
|
"disable loading non-context-aware addons",
|
||||||
|
&EnvironmentOptions::force_context_aware,
|
||||||
|
kAllowedInEnvironment);
|
||||||
AddOption("--pending-deprecation",
|
AddOption("--pending-deprecation",
|
||||||
"emit pending deprecation warnings",
|
"emit pending deprecation warnings",
|
||||||
&EnvironmentOptions::pending_deprecation,
|
&EnvironmentOptions::pending_deprecation,
|
||||||
|
@ -116,6 +116,7 @@ class EnvironmentOptions : public Options {
|
|||||||
bool no_deprecation = false;
|
bool no_deprecation = false;
|
||||||
bool no_force_async_hooks_checks = false;
|
bool no_force_async_hooks_checks = false;
|
||||||
bool no_warnings = false;
|
bool no_warnings = false;
|
||||||
|
bool force_context_aware = false;
|
||||||
bool pending_deprecation = false;
|
bool pending_deprecation = false;
|
||||||
bool preserve_symlinks = false;
|
bool preserve_symlinks = false;
|
||||||
bool preserve_symlinks_main = false;
|
bool preserve_symlinks_main = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user