From 321e296371383fd63131d21c1121e22163ddeb86 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sun, 16 Dec 2018 03:13:12 +0800 Subject: process: move POSIX credential accessors into node_credentials.cc Expose the POSIX credential accessors through `internalBinding('credentials')` instead of setting them on the process or bootstrapper object from C++ directly. Also moves `SafeGetEnv` from `internalBinding('util')` to `internalBinding('credentials')` since it's closely related to the credentials. In the JS land, instead of wrapping the bindings then writing to the process object directly in main_thread_only.js, return the wrapped functions back to bootstrap/node.js where they get written to the process object conditionally for clarity. Refs: https://github.com/nodejs/node/issues/24961 PR-URL: https://github.com/nodejs/node/pull/25066 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- src/node_internals.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/node_internals.h') diff --git a/src/node_internals.h b/src/node_internals.h index d9a72a10a4..2c6aad5b96 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -126,7 +126,6 @@ void RegisterSignalHandler(int signal, bool reset_handler = false); #endif -bool SafeGetenv(const char* key, std::string* text); v8::Local CreateEnvVarProxy(v8::Local context, v8::Isolate* isolate, v8::Local data); @@ -734,19 +733,13 @@ void ProcessTitleSetter(v8::Local property, const v8::PropertyCallbackInfo& info); #if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__) -void SetGid(const v8::FunctionCallbackInfo& args); -void SetEGid(const v8::FunctionCallbackInfo& args); -void SetUid(const v8::FunctionCallbackInfo& args); -void SetEUid(const v8::FunctionCallbackInfo& args); -void SetGroups(const v8::FunctionCallbackInfo& args); -void InitGroups(const v8::FunctionCallbackInfo& args); -void GetUid(const v8::FunctionCallbackInfo& args); -void GetGid(const v8::FunctionCallbackInfo& args); -void GetEUid(const v8::FunctionCallbackInfo& args); -void GetEGid(const v8::FunctionCallbackInfo& args); -void GetGroups(const v8::FunctionCallbackInfo& args); +#define NODE_IMPLEMENTS_POSIX_CREDENTIALS 1 #endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__) +namespace credentials { +bool SafeGetenv(const char* key, std::string* text); +} // namespace credentials + void DefineZlibConstants(v8::Local target); } // namespace node -- cgit v1.2.3