diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-09-05 13:28:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-05 13:28:23 +0200 |
commit | e0ddabb0d674c597ae8b0dc3eb6b8511bc9a1df1 (patch) | |
tree | cd8947808b49c9f6d3140ffaaa21b3e2798dbd05 | |
parent | 5e0a7206f59df575582f42415fc3df59b0d640cb (diff) | |
parent | 74f6d8767de13980b0e83a249633ee4a7e6fc547 (diff) |
Merge pull request #2400 from matthewbauer/patch-9
Get effective user in Nix commands
-rw-r--r-- | src/libutil/util.cc | 2 | ||||
-rwxr-xr-x | src/nix-channel/nix-channel.cc | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 6bc64ae75..04c98dc80 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -468,7 +468,7 @@ static Lazy<Path> getHome2([]() { std::vector<char> buf(16384); struct passwd pwbuf; struct passwd * pw; - if (getpwuid_r(getuid(), &pwbuf, buf.data(), buf.size(), &pw) != 0 + if (getpwuid_r(geteuid(), &pwbuf, buf.data(), buf.size(), &pw) != 0 || !pw || !pw->pw_dir || !pw->pw_dir[0]) throw Error("cannot determine user's home directory"); homeDir = pw->pw_dir; diff --git a/src/nix-channel/nix-channel.cc b/src/nix-channel/nix-channel.cc index 55ebda438..2083d3df5 100755 --- a/src/nix-channel/nix-channel.cc +++ b/src/nix-channel/nix-channel.cc @@ -169,7 +169,7 @@ int main(int argc, char ** argv) // Figure out the name of the channels profile. ; - auto pw = getpwuid(getuid()); + auto pw = getpwuid(geteuid()); std::string name = pw ? pw->pw_name : getEnv("USER", ""); if (name.empty()) throw Error("cannot figure out user name"); |