summaryrefslogtreecommitdiff
path: root/src/node_main.cc
diff options
context:
space:
mode:
authorDaniel Bevenius <daniel.bevenius@gmail.com>2017-04-20 20:08:53 +0200
committerDaniel Bevenius <daniel.bevenius@gmail.com>2017-05-25 19:05:14 +0200
commit6caf1b093ab0176b8ded68a53ab1ab72259bb1e0 (patch)
tree26078501535acdc0c74efb7a5c20eee4b825fb19 /src/node_main.cc
parent1cde37576392f16c8652cde62804c248c77f70fb (diff)
downloadandroid-node-v8-6caf1b093ab0176b8ded68a53ab1ab72259bb1e0.tar.gz
android-node-v8-6caf1b093ab0176b8ded68a53ab1ab72259bb1e0.tar.bz2
android-node-v8-6caf1b093ab0176b8ded68a53ab1ab72259bb1e0.zip
src: add linux getauxval(AT_SECURE) in SafeGetenv
This commit attempts to fix the following TODO: // TODO(bnoordhuis) Should perhaps also check whether getauxval(AT_SECURE) is non-zero on Linux. This can be manually tested at the moment using the following steps: $ setcap cap_net_raw+ep out/Release/node $ NODE_PENDING_DEPRECATION="1" out/Release/node -p "process.binding('config').pendingDeprecation" true $ useradd test $ su test $ NODE_PENDING_DEPRECATION="1" out/Release/node -p "process.binding('config').pendingDeprecation" undefined PR-URL: https://github.com/nodejs/node/pull/12548 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/node_main.cc')
-rw-r--r--src/node_main.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/node_main.cc b/src/node_main.cc
index 3194eb78ca..7d6d9b1a01 100644
--- a/src/node_main.cc
+++ b/src/node_main.cc
@@ -71,7 +71,32 @@ int wmain(int argc, wchar_t *wargv[]) {
}
#else
// UNIX
+#ifdef __linux__
+#include <elf.h>
+#ifdef __LP64__
+#define Elf_auxv_t Elf64_auxv_t
+#else
+#define Elf_auxv_t Elf32_auxv_t
+#endif // __LP64__
+extern char** environ;
+#endif // __linux__
+
+namespace node {
+ extern bool linux_at_secure;
+} // namespace node
+
int main(int argc, char *argv[]) {
+#if defined(__linux__)
+ char** envp = environ;
+ while (*envp++ != nullptr) {}
+ Elf_auxv_t* auxv = reinterpret_cast<Elf_auxv_t*>(envp);
+ for (; auxv->a_type != AT_NULL; auxv++) {
+ if (auxv->a_type == AT_SECURE) {
+ node::linux_at_secure = auxv->a_un.a_val;
+ break;
+ }
+ }
+#endif
// Disable stdio buffering, it interacts poorly with printf()
// calls elsewhere in the program (e.g., any logging from V8.)
setvbuf(stdout, nullptr, _IONBF, 0);