From 3a6b130abcc3ceed7ac9300b67369f26170f17d0 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Mon, 30 Oct 2017 11:58:13 +0100 Subject: [PATCH 1/3] build: Add CloudABI as a POSIX-like runtime environment. CloudABI is a compact POSIX-like runtime that makes use of capability-based security. More details: https://github.com/NuxiNL/cloudlibc --- common.gypi | 2 +- configure | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common.gypi b/common.gypi index 6677274f3abe80..cf5bdaa928e727 100644 --- a/common.gypi +++ b/common.gypi @@ -279,7 +279,7 @@ 'cflags': [ '-pthread', ], 'ldflags': [ '-pthread' ], }], - [ 'OS in "linux freebsd openbsd solaris android aix"', { + [ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', { 'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ], 'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++0x' ], 'ldflags': [ '-rdynamic' ], diff --git a/configure b/configure index 4e3455056cfb98..d0b2540c2f0aaa 100755 --- a/configure +++ b/configure @@ -57,7 +57,7 @@ from gyp_node import run_gyp parser = optparse.OptionParser() valid_os = ('win', 'mac', 'solaris', 'freebsd', 'openbsd', 'linux', - 'android', 'aix') + 'android', 'aix', 'cloudabi') valid_arch = ('arm', 'arm64', 'ia32', 'mips', 'mipsel', 'mips64el', 'ppc', 'ppc64', 'x32','x64', 'x86', 's390', 's390x') valid_arm_float_abi = ('soft', 'softfp', 'hard') From c71500769318c1a1485ccadaf66ea52a4cebba3e Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Mon, 30 Oct 2017 12:01:35 +0100 Subject: [PATCH 2/3] src: Disable use of pwd.h, grp.h and get*uid() on CloudABI. As CloudABI is intended to run applications in cluster contexts (e.g., on Kubernetes), they are oblivious of UNIX credentials. Extend the existing preprocessor checks to disable any use of these interfaces, just like on Windows, Android, etc. --- src/node.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node.cc b/src/node.cc index 0c69ece87ad366..c58c910fb52447 100644 --- a/src/node.cc +++ b/src/node.cc @@ -111,7 +111,7 @@ typedef int mode_t; #include // setuid, getuid #endif -#if defined(__POSIX__) && !defined(__ANDROID__) +#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__) #include // getpwnam() #include // getgrnam() #endif @@ -998,7 +998,7 @@ Local UVException(Isolate* isolate, // Look up environment variable unless running as setuid root. bool SafeGetenv(const char* key, std::string* text) { -#ifndef _WIN32 +#if !defined(__CloudABI__) && !defined(_WIN32) if (linux_at_secure || getuid() != geteuid() || getgid() != getegid()) goto fail; #endif @@ -2082,7 +2082,7 @@ static void Umask(const FunctionCallbackInfo& args) { } -#if defined(__POSIX__) && !defined(__ANDROID__) +#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__) static const uid_t uid_not_found = static_cast(-1); static const gid_t gid_not_found = static_cast(-1); @@ -2401,7 +2401,7 @@ static void InitGroups(const FunctionCallbackInfo& args) { } } -#endif // __POSIX__ && !defined(__ANDROID__) +#endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__) static void WaitForInspectorDisconnect(Environment* env) { @@ -3610,7 +3610,7 @@ void SetupProcessObject(Environment* env, env->SetMethod(process, "umask", Umask); -#if defined(__POSIX__) && !defined(__ANDROID__) +#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__) env->SetMethod(process, "getuid", GetUid); env->SetMethod(process, "geteuid", GetEUid); env->SetMethod(process, "setuid", SetUid); @@ -3624,7 +3624,7 @@ void SetupProcessObject(Environment* env, env->SetMethod(process, "getgroups", GetGroups); env->SetMethod(process, "setgroups", SetGroups); env->SetMethod(process, "initgroups", InitGroups); -#endif // __POSIX__ && !defined(__ANDROID__) +#endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__) env->SetMethod(process, "_kill", Kill); From dc2ae93b1489fcde2cb8007526f22982165cee36 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Mon, 30 Oct 2017 12:17:30 +0100 Subject: [PATCH 3/3] src: Explicitly include . cares_wrap.cc calls into functions like getnameinfo() and getaddrinfo(). These functions tend to be available implicitly through , but we'd better still include this header explicitly. On CloudABI, we make use of a custom implementation of libuv that does not implicitly include header files like . --- src/cares_wrap.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index e800e0f2fee260..59f021fd49d448 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -38,6 +38,10 @@ #include #include +#ifdef __POSIX__ +# include +#endif // __POSIX__ + #if defined(__ANDROID__) || \ defined(__MINGW32__) || \ defined(__OpenBSD__) || \