| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a74c373 commit 306c1d3
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,10 +62,9 @@ EnabledDebugList enabled_debug_list; | |||
| 62 | 62 | using v8::Local; | |
| 63 | 63 | using v8::StackTrace; | |
| 64 | 64 | ||
| 65 | - void EnabledDebugList::Parse(std::shared_ptr<KVStore> env_vars, | ||
| 66 | - v8::Isolate* isolate) { | ||
| 65 | + void EnabledDebugList::Parse(std::shared_ptr<KVStore> env_vars) { | ||
| 67 | 66 | std::string cats; | |
| 68 | - credentials::SafeGetenv("NODE_DEBUG_NATIVE", &cats, env_vars, isolate); | ||
| 67 | + credentials::SafeGetenv("NODE_DEBUG_NATIVE", &cats, env_vars); | ||
| 69 | 68 | Parse(cats); | |
| 70 | 69 | } | |
| 71 | 70 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,8 +74,7 @@ class NODE_EXTERN_PRIVATE EnabledDebugList { | |||
| 74 | 74 | // Uses NODE_DEBUG_NATIVE to initialize the categories. The env_vars variable | |
| 75 | 75 | // is parsed if it is not a nullptr, otherwise the system environment | |
| 76 | 76 | // variables are parsed. | |
| 77 | - void Parse(std::shared_ptr<KVStore> env_vars = nullptr, | ||
| 78 | - v8::Isolate* isolate = nullptr); | ||
| 77 | + void Parse(std::shared_ptr<KVStore> env_vars); | ||
| 79 | 78 | ||
| 80 | 79 | private: | |
| 81 | 80 | // Enable all categories matching cats. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -848,7 +848,7 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 848 | 848 | } | |
| 849 | 849 | ||
| 850 | 850 | set_env_vars(per_process::system_environment); | |
| 851 | - enabled_debug_list_.Parse(env_vars(), isolate); | ||
| 851 | + enabled_debug_list_.Parse(env_vars()); | ||
| 852 | 852 | ||
| 853 | 853 | // We create new copies of the per-Environment option sets, so that it is | |
| 854 | 854 | // easier to modify them after Environment creation. The defaults are | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -418,12 +418,9 @@ void StartProfilers(Environment* env) { | |||
| 418 | 418 | EndStartedProfilers(static_cast<Environment*>(env)); | |
| 419 | 419 | }, env); | |
| 420 | 420 | ||
| 421 | - Isolate* isolate = env->isolate(); | ||
| 422 | - Local<String> coverage_str = env->env_vars()->Get( | ||
| 423 | - isolate, FIXED_ONE_BYTE_STRING(isolate, "NODE_V8_COVERAGE")) | ||
| 424 | - .FromMaybe(Local<String>()); | ||
| 425 | - if ((!coverage_str.IsEmpty() && coverage_str->Length() > 0) || | ||
| 426 | - env->options()->test_runner_coverage) { | ||
| 421 | + std::string coverage_str = | ||
| 422 | + env->env_vars()->Get("NODE_V8_COVERAGE").FromMaybe(std::string()); | ||
| 423 | + if (!coverage_str.empty() || env->options()->test_runner_coverage) { | ||
| 427 | 424 | CHECK_NULL(env->coverage_connection()); | |
| 428 | 425 | env->set_coverage_connection(std::make_unique<V8CoverageConnection>(env)); | |
| 429 | 426 | env->coverage_connection()->Start(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1030,7 +1030,7 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args, | |||
| 1030 | 1030 | if (!(flags & ProcessInitializationFlags::kNoParseGlobalDebugVariables)) { | |
| 1031 | 1031 | // Initialized the enabled list for Debug() calls with system | |
| 1032 | 1032 | // environment variables. | |
| 1033 | - per_process::enabled_debug_list.Parse(); | ||
| 1033 | + per_process::enabled_debug_list.Parse(per_process::system_environment); | ||
| 1034 | 1034 | } | |
| 1035 | 1035 | ||
| 1036 | 1036 | PlatformInit(flags); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,13 +24,10 @@ namespace node { | |||
| 24 | 24 | using v8::Array; | |
| 25 | 25 | using v8::Context; | |
| 26 | 26 | using v8::FunctionCallbackInfo; | |
| 27 | - using v8::HandleScope; | ||
| 28 | 27 | using v8::Isolate; | |
| 29 | 28 | using v8::Local; | |
| 30 | 29 | using v8::MaybeLocal; | |
| 31 | 30 | using v8::Object; | |
| 32 | - using v8::String; | ||
| 33 | - using v8::TryCatch; | ||
| 34 | 31 | using v8::Uint32; | |
| 35 | 32 | using v8::Value; | |
| 36 | 33 | ||
@@ -77,54 +74,24 @@ static bool HasOnly(int capability) { | |||
| 77 | 74 | // setuid root then lookup will not be allowed. | |
| 78 | 75 | bool SafeGetenv(const char* key, | |
| 79 | 76 | std::string* text, | |
| 80 | - std::shared_ptr<KVStore> env_vars, | ||
| 81 | - v8::Isolate* isolate) { | ||
| 77 | + std::shared_ptr<KVStore> env_vars) { | ||
| 82 | 78 | #if !defined(__CloudABI__) && !defined(_WIN32) | |
| 83 | 79 | #if defined(__linux__) | |
| 84 | 80 | if ((!HasOnly(CAP_NET_BIND_SERVICE) && linux_at_secure()) || | |
| 85 | 81 | getuid() != geteuid() || getgid() != getegid()) | |
| 86 | 82 | #else | |
| 87 | 83 | if (linux_at_secure() || getuid() != geteuid() || getgid() != getegid()) | |
| 88 | 84 | #endif | |
| 89 | - goto fail; | ||
| 85 | + return false; | ||
| 90 | 86 | #endif | |
| 91 | 87 | ||
| 92 | - if (env_vars != nullptr) { | ||
| 93 | - DCHECK_NOT_NULL(isolate); | ||
| 94 | - HandleScope handle_scope(isolate); | ||
| 95 | - TryCatch ignore_errors(isolate); | ||
| 96 | - MaybeLocal<String> maybe_value = env_vars->Get( | ||
| 97 | - isolate, String::NewFromUtf8(isolate, key).ToLocalChecked()); | ||
| 98 | - Local<String> value; | ||
| 99 | - if (!maybe_value.ToLocal(&value)) goto fail; | ||
| 100 | - String::Utf8Value utf8_value(isolate, value); | ||
| 101 | - if (*utf8_value == nullptr) goto fail; | ||
| 102 | - *text = std::string(*utf8_value, utf8_value.length()); | ||
| 103 | - return true; | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - { | ||
| 107 | - Mutex::ScopedLock lock(per_process::env_var_mutex); | ||
| 108 | - | ||
| 109 | - size_t init_sz = 256; | ||
| 110 | - MaybeStackBuffer<char, 256> val; | ||
| 111 | - int ret = uv_os_getenv(key, *val, &init_sz); | ||
| 112 | - | ||
| 113 | - if (ret == UV_ENOBUFS) { | ||
| 114 | - // Buffer is not large enough, reallocate to the updated init_sz | ||
| 115 | - // and fetch env value again. | ||
| 116 | - val.AllocateSufficientStorage(init_sz); | ||
| 117 | - ret = uv_os_getenv(key, *val, &init_sz); | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - if (ret == 0) { // Env key value fetch success. | ||
| 121 | - *text = *val; | ||
| 122 | - return true; | ||
| 123 | - } | ||
| 88 | + // Fallback to system environment which reads the real environment variable | ||
| 89 | + // through uv_os_getenv. | ||
| 90 | + if (env_vars == nullptr) { | ||
| 91 | + env_vars = per_process::system_environment; | ||
| 124 | 92 | } | |
| 125 | 93 | ||
| 126 | - fail: | ||
| 127 | - return false; | ||
| 94 | + return env_vars->Get(key).To(text); | ||
| 128 | 95 | } | |
| 129 | 96 | ||
| 130 | 97 | static void SafeGetenv(const FunctionCallbackInfo<Value>& args) { | |
@@ -133,7 +100,7 @@ static void SafeGetenv(const FunctionCallbackInfo<Value>& args) { | |||
| 133 | 100 | Isolate* isolate = env->isolate(); | |
| 134 | 101 | Utf8Value strenvtag(isolate, args[0]); | |
| 135 | 102 | std::string text; | |
| 136 | - if (!SafeGetenv(*strenvtag, &text, env->env_vars(), isolate)) return; | ||
| 103 | + if (!SafeGetenv(*strenvtag, &text, env->env_vars())) return; | ||
| 137 | 104 | Local<Value> result = | |
| 138 | 105 | ToV8Value(isolate->GetCurrentContext(), text).ToLocalChecked(); | |
| 139 | 106 | args.GetReturnValue().Set(result); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -308,8 +308,7 @@ class ThreadPoolWork { | |||
| 308 | 308 | namespace credentials { | |
| 309 | 309 | bool SafeGetenv(const char* key, | |
| 310 | 310 | std::string* text, | |
| 311 | - std::shared_ptr<KVStore> env_vars = nullptr, | ||
| 312 | - v8::Isolate* isolate = nullptr); | ||
| 311 | + std::shared_ptr<KVStore> env_vars = nullptr); | ||
| 313 | 312 | } // namespace credentials | |
| 314 | 313 | ||
| 315 | 314 | void DefineZlibConstants(v8::Local<v8::Object> target); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,6 @@ using v8::Isolate; | |||
| 32 | 32 | using v8::Local; | |
| 33 | 33 | using v8::Locker; | |
| 34 | 34 | using v8::Maybe; | |
| 35 | - using v8::MaybeLocal; | ||
| 36 | 35 | using v8::Null; | |
| 37 | 36 | using v8::Number; | |
| 38 | 37 | using v8::Object; | |
@@ -537,11 +536,8 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) { | |||
| 537 | 536 | }); | |
| 538 | 537 | ||
| 539 | 538 | #ifndef NODE_WITHOUT_NODE_OPTIONS | |
| 540 | - MaybeLocal<String> maybe_node_opts = | ||
| 541 | - env_vars->Get(isolate, OneByteString(isolate, "NODE_OPTIONS")); | ||
| 542 | - Local<String> node_opts; | ||
| 543 | - if (maybe_node_opts.ToLocal(&node_opts)) { | ||
| 544 | - std::string node_options(*String::Utf8Value(isolate, node_opts)); | ||
| 539 | + std::string node_options; | ||
| 540 | + if (env_vars->Get("NODE_OPTIONS").To(&node_options)) { | ||
| 545 | 541 | std::vector<std::string> errors{}; | |
| 546 | 542 | std::vector<std::string> env_argv = | |
| 547 | 543 | ParseNodeOptionsEnvVar(node_options, &errors); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments