Skip to content

Commit f3e0161

Browse files
EdSchoutencjihrig
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: #16612 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent ffe4d7b commit f3e0161

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
'cflags': [ '-pthread', ],
292292
'ldflags': [ '-pthread' ],
293293
}],
294-
[ 'OS in "linux freebsd openbsd solaris android aix"', {
294+
[ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', {
295295
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
296296
'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++0x' ],
297297
'ldflags': [ '-rdynamic' ],

configure

+1-1
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

+4
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

+6-6
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
@@ -1002,7 +1002,7 @@ Local<Value> UVException(Isolate* isolate,
10021002

10031003
// Look up environment variable unless running as setuid root.
10041004
bool SafeGetenv(const char* key, std::string* text) {
1005-
#ifndef _WIN32
1005+
#if !defined(__CloudABI__) && !defined(_WIN32)
10061006
if (linux_at_secure || getuid() != geteuid() || getgid() != getegid())
10071007
goto fail;
10081008
#endif
@@ -2122,7 +2122,7 @@ static void Umask(const FunctionCallbackInfo<Value>& args) {
21222122
}
21232123

21242124

2125-
#if defined(__POSIX__) && !defined(__ANDROID__)
2125+
#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__)
21262126

21272127
static const uid_t uid_not_found = static_cast<uid_t>(-1);
21282128
static const gid_t gid_not_found = static_cast<gid_t>(-1);
@@ -2441,7 +2441,7 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
24412441
}
24422442
}
24432443

2444-
#endif // __POSIX__ && !defined(__ANDROID__)
2444+
#endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__)
24452445

24462446

24472447
static void WaitForInspectorDisconnect(Environment* env) {
@@ -3706,7 +3706,7 @@ void SetupProcessObject(Environment* env,
37063706

37073707
env->SetMethod(process, "umask", Umask);
37083708

3709-
#if defined(__POSIX__) && !defined(__ANDROID__)
3709+
#if defined(__POSIX__) && !defined(__ANDROID__) && !defined(__CloudABI__)
37103710
env->SetMethod(process, "getuid", GetUid);
37113711
env->SetMethod(process, "geteuid", GetEUid);
37123712
env->SetMethod(process, "setuid", SetUid);
@@ -3720,7 +3720,7 @@ void SetupProcessObject(Environment* env,
37203720
env->SetMethod(process, "getgroups", GetGroups);
37213721
env->SetMethod(process, "setgroups", SetGroups);
37223722
env->SetMethod(process, "initgroups", InitGroups);
3723-
#endif // __POSIX__ && !defined(__ANDROID__)
3723+
#endif // __POSIX__ && !defined(__ANDROID__) && !defined(__CloudABI__)
37243724

37253725
env->SetMethod(process, "_kill", Kill);
37263726

0 commit comments

Comments
 (0)