Skip to content

Commit

Permalink
src: add SafeGetenv() to internal API
Browse files Browse the repository at this point in the history
Allow it to be used anywhere in src/ that env variables with security
implications are accessed.
  • Loading branch information
sam-github committed Feb 9, 2017
1 parent 46edd94 commit 901e926
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ Local<Value> UVException(Isolate* isolate,


// Look up environment variable unless running as setuid root.
inline bool SafeGetenv(const char* key, std::string* text) {
bool SafeGetenv(const char* key, std::string* text) {
#ifndef _WIN32
// TODO(bnoordhuis) Should perhaps also check whether getauxval(AT_SECURE)
// is non-zero on Linux.
Expand Down
2 changes: 2 additions & 0 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ void RegisterSignalHandler(int signal,
bool reset_handler = false);
#endif

bool SafeGetenv(const char* key, std::string* text);

template <typename T, size_t N>
constexpr size_t arraysize(const T(&)[N]) { return N; }

Expand Down

5 comments on commit 901e926

@gibfahn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR-URL: #11006
Reviewed-By: Michael Dawson michael_dawson@ca.ibm.com
Reviewed-By: Ben Noordhuis info@bnoordhuis.nl

@sam-github
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw @addaleax create a git note for a situation like this, so I just tried, but it looks like they are no longer display by github :-(. https://github.com/blog/707-git-notes-display

I can see them when I added fetch = +refs/notes/*:refs/notes/* to my fetch refspec, but I'm not sure if that was useful.

@addaleax
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sam-github huh? I don’t remember ever doing that, maybe you meant to @mention somebody else? 😄

@sam-github
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? :-) I was pretty sure it was you, but I also have a fabulously bad memory.

@addaleax
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I have literally no idea how to do that kind of thing ;) Seems like a good idea if it works, though.

Please sign in to comment.