diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2025-07-10 15:25:29 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-07-16 23:50:51 +0200 |
| commit | 9cd3b961e4e530b4361ef25132fc8ee9756aab4b (patch) | |
| tree | 832f0d521682e3858530f8d74193ef24d85c4c05 /nix/nix-daemon | |
| parent | 38e82ca727512754c4ac9b43353255c91cadab8c (diff) | |
daemon: Consider the current user as trusted.
This allows use of ‘guix gc --verify=repair’ when running guix-daemon as
an unprivileged user.
* nix/nix-daemon/nix-daemon.cc (acceptConnection): Consider the current
user as trusted.
Reported-by: David Elsing <david.elsing@posteo.net>
Change-Id: I559e56cf0640e8dc9bbc510317aa2bdc024ff681
Diffstat (limited to 'nix/nix-daemon')
| -rw-r--r-- | nix/nix-daemon/nix-daemon.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc index 9fff31a587c..f2ffe8fa6f8 100644 --- a/nix/nix-daemon/nix-daemon.cc +++ b/nix/nix-daemon/nix-daemon.cc | |||
| @@ -963,7 +963,10 @@ static void acceptConnection(int fdSocket) | |||
| 963 | clientPid = cred.pid; | 963 | clientPid = cred.pid; |
| 964 | clientUid = cred.uid; | 964 | clientUid = cred.uid; |
| 965 | clientGid = cred.gid; | 965 | clientGid = cred.gid; |
| 966 | trusted = clientUid == 0; | 966 | |
| 967 | /* The root user is always trusted; additionally, when running as | ||
| 968 | an unprivileged user, that user is also trusted. */ | ||
| 969 | trusted = (clientUid == 0) || (clientUid == getuid()); | ||
| 967 | 970 | ||
| 968 | struct passwd * pw = getpwuid(cred.uid); | 971 | struct passwd * pw = getpwuid(cred.uid); |
| 969 | string user = pw ? pw->pw_name : std::to_string(cred.uid); | 972 | string user = pw ? pw->pw_name : std::to_string(cred.uid); |
