1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 06:01:48 +02:00

Merge pull request #10363 from obsidiansystems/is-root-user

Factor out `isRootUser` function
This commit is contained in:
Théophane Hufschmitt 2024-03-30 07:15:56 +01:00 committed by GitHub
commit 845b2a9256
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 30 additions and 15 deletions

View file

@ -113,4 +113,9 @@ std::string expandTilde(std::string_view path)
return std::string(path);
}
bool isRootUser() {
return getuid() == 0;
}
}

View file

@ -55,4 +55,10 @@ Path createNixStateDir();
*/
std::string expandTilde(std::string_view path);
/**
* Is the current user UID 0 on Unix?
*/
bool isRootUser();
}