Skip to content
Permalink
Browse files

src: reduce duplicate code in SafeGetenv()

PR-URL: #13220
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information...
cjihrig authored and jasnell committed May 25, 2017
1 parent 9fa1489 commit ac2e8820c4c4188e54afa0cf0d9fea8ec823e15d
Showing with 5 additions and 8 deletions.
  1. +5 −8 src/node.cc
@@ -975,19 +975,16 @@ Local<Value> UVException(Isolate* isolate,
// Look up environment variable unless running as setuid root.
bool SafeGetenv(const char* key, std::string* text) {
#ifndef _WIN32
if (getuid() != geteuid() || getgid() != getegid()) {
text->clear();
return false;
}
if (linux_at_secure || getuid() != geteuid() || getgid() != getegid())
goto fail;
#endif
if (linux_at_secure) {
text->clear();
return false;
}

if (const char* value = getenv(key)) {
*text = value;
return true;
}

fail:
text->clear();
return false;
}

0 comments on commit ac2e882

Please sign in to comment.
You can’t perform that action at this time.