Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: clean up SafeGetenv() #13220

Merged
merged 1 commit into from
May 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down