Merge "daemon: get peer pid, gid for socket connection on darwin" into main
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
---
|
||||
synopsis: "Fetch peer PID for daemon connections on macOS"
|
||||
issues: [fj#640]
|
||||
cls: [2453]
|
||||
category: Fixes
|
||||
credits: [lilyball]
|
||||
---
|
||||
|
||||
`nix-daemon` will now fetch the peer PID for connections on macOS, to match behavior with Linux.
|
||||
Besides showing up in the log output line, If `nix-daemon` is given an argument (such as `--daemon`)
|
||||
that argument will be overwritten with the peer PID for the forked process that handles the connection,
|
||||
which can be used for debugging purposes.
|
||||
+7
-1
@@ -188,7 +188,13 @@ static PeerInfo getPeerInfo(int remote)
|
||||
socklen_t credLen = sizeof(cred);
|
||||
if (getsockopt(remote, SOL_LOCAL, LOCAL_PEERCRED, &cred, &credLen) == -1)
|
||||
throw SysError("getting peer credentials");
|
||||
peer = { false, 0, true, cred.cr_uid, false, 0 };
|
||||
peer = { false, 0, true, cred.cr_uid, true, cred.cr_gid };
|
||||
|
||||
#if defined(LOCAL_PEERPID)
|
||||
socklen_t pidLen = sizeof(peer.pid);
|
||||
if (!getsockopt(remote, SOL_LOCAL, LOCAL_PEERPID, &peer.pid, &pidLen))
|
||||
peer.pidKnown = true;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<array>
|
||||
<string>/bin/sh</string>
|
||||
<string>-c</string>
|
||||
<string>/bin/wait4path /nix/var/nix/profiles/default/bin/nix-daemon && exec /nix/var/nix/profiles/default/bin/nix-daemon</string>
|
||||
<string>/bin/wait4path /nix/var/nix/profiles/default/bin/nix-daemon && exec /nix/var/nix/profiles/default/bin/nix-daemon --daemon</string>
|
||||
</array>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/var/log/nix-daemon.log</string>
|
||||
|
||||
Reference in New Issue
Block a user