mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Merge pull request #2400 from matthewbauer/patch-9
Get effective user in Nix commands
This commit is contained in:
commit
e0ddabb0d6
2 changed files with 2 additions and 2 deletions
|
@ -468,7 +468,7 @@ static Lazy<Path> getHome2([]() {
|
||||||
std::vector<char> buf(16384);
|
std::vector<char> buf(16384);
|
||||||
struct passwd pwbuf;
|
struct passwd pwbuf;
|
||||||
struct passwd * pw;
|
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])
|
|| !pw || !pw->pw_dir || !pw->pw_dir[0])
|
||||||
throw Error("cannot determine user's home directory");
|
throw Error("cannot determine user's home directory");
|
||||||
homeDir = pw->pw_dir;
|
homeDir = pw->pw_dir;
|
||||||
|
|
|
@ -169,7 +169,7 @@ int main(int argc, char ** argv)
|
||||||
|
|
||||||
// Figure out the name of the channels profile.
|
// 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", "");
|
std::string name = pw ? pw->pw_name : getEnv("USER", "");
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
throw Error("cannot figure out user name");
|
throw Error("cannot figure out user name");
|
||||||
|
|
Loading…
Reference in a new issue