electron/shell/common/node_util_mac.mm
Cheng Zhao dfce1a9eb4
fix: ignore all NODE_ envs from foreign parent in node process (#40770)
* fix: ignore all NODE_ envs from foreign parent

* fix: recognize ad-hoc signed binary
2024-01-04 16:34:08 +09:00

23 lines
587 B
Text

// Copyright (c) 2023 Microsoft, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/common/node_util.h"
#include <Foundation/Foundation.h>
namespace electron::util {
bool UnsetAllNodeEnvs() {
bool has_unset = false;
for (NSString* env in NSProcessInfo.processInfo.environment) {
if (![env hasPrefix:@"NODE_"])
continue;
const char* name = [[env componentsSeparatedByString:@"="][0] UTF8String];
unsetenv(name);
has_unset = true;
}
return has_unset;
}
} // namespace electron::util