Skip to content
This repository was archived by the owner on Aug 31, 2018. It is now read-only.

Commit 542ad68

Browse files
EdSchoutenaddaleax
authored andcommitted
build,src: 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 * 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: Explicitly include <netdb.h>. cares_wrap.cc calls into functions like getnameinfo() and getaddrinfo(). These functions tend to be available implicitly through <uv.h>, 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 <netdb.h>. PR-URL: nodejs/node#16612 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent f8f63fa commit 542ad68

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
'cflags': [ '-pthread', ],
297297
'ldflags': [ '-pthread' ],
298298
}],
299-
[ 'OS in "linux freebsd openbsd solaris android aix"', {
299+
[ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', {
300300
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
301301
'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++0x' ],
302302
'ldflags': [ '-rdynamic' ],

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ from gyp_node import run_gyp
5757
parser = optparse.OptionParser()
5858

5959
valid_os = ('win', 'mac', 'solaris', 'freebsd', 'openbsd', 'linux',
60-
'android', 'aix')
60+
'android', 'aix', 'cloudabi')
6161
valid_arch = ('arm', 'arm64', 'ia32', 'mips', 'mipsel', 'mips64el', 'ppc',
6262
'ppc64', 'x32','x64', 'x86', 's390', 's390x')
6363
valid_arm_float_abi = ('soft', 'softfp', 'hard')

src/cares_wrap.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include <vector>
3535
#include <unordered_set>
3636

37+
#ifdef __POSIX__
38+
# include <netdb.h>
39+
#endif // __POSIX__
40+
3741
#if defined(__ANDROID__) || \
3842
defined(__MINGW32__) || \
3943
defined(__OpenBSD__) || \

src/node.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ typedef int mode_t;
108108
#include <unistd.h> // setuid, getuid
109109
#endif
110110

111-
#if defined(__POSIX__) && !defined(__ANDROID__)
111+
#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__)
112112
#include <pwd.h> // getpwnam()
113113
#include <grp.h> // getgrnam()
114114
#endif
@@ -1018,7 +1018,7 @@ Local<Value> UVException(Isolate* isolate,
10181018

10191019
// Look up environment variable unless running as setuid root.
10201020
bool SafeGetenv(const char* key, std::string* text) {
1021-
#ifndef _WIN32
1021+
#if !defined(__CloudABI__) && !defined(_WIN32)
10221022
if (linux_at_secure || getuid() != geteuid() || getgid() != getegid())
10231023
goto fail;
10241024
#endif
@@ -2172,7 +2172,7 @@ static void Umask(const FunctionCallbackInfo<Value>& args) {
21722172
}
21732173

21742174

2175-
#if defined(__POSIX__) && !defined(__ANDROID__)
2175+
#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__)
21762176

21772177
static const uid_t uid_not_found = static_cast<uid_t>(-1);
21782178
static const gid_t gid_not_found = static_cast<gid_t>(-1);
@@ -2495,7 +2495,7 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
24952495
}
24962496
}
24972497

2498-
#endif // __POSIX__ && !defined(__ANDROID__)
2498+
#endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__)
24992499

25002500

25012501
static void WaitForInspectorDisconnect(Environment* env) {
@@ -3860,7 +3860,7 @@ void SetupProcessObject(Environment* env,
38603860

38613861
env->SetMethod(process, "umask", Umask);
38623862

3863-
#if defined(__POSIX__) && !defined(__ANDROID__)
3863+
#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__)
38643864
env->SetMethod(process, "getuid", GetUid);
38653865
env->SetMethod(process, "geteuid", GetEUid);
38663866
env->SetMethod(process, "getgid", GetGid);
@@ -3877,7 +3877,7 @@ void SetupProcessObject(Environment* env,
38773877
env->SetMethod(process, "setgroups", SetGroups);
38783878
env->SetMethod(process, "initgroups", InitGroups);
38793879
}
3880-
#endif // __POSIX__ && !defined(__ANDROID__)
3880+
#endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__)
38813881

38823882
env->SetMethod(process, "_kill", Kill);
38833883
env->SetMethod(process, "dlopen", DLOpen);

0 commit comments

Comments
 (0)