From 7b2b4d03bb705a76573649c275d497a7a86407f5 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 3 Jul 2024 11:15:56 -0400 Subject: [PATCH 1/2] Ident some CPP in nix daemon Makes it easier for me to read. (cherry picked from commit a09360400bc0f43e865273ba1ccb2b513d8a962e) --- src/nix/daemon.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nix/daemon.cc b/src/nix/daemon.cc index 373dedf7c..9ab7d15a3 100644 --- a/src/nix/daemon.cc +++ b/src/nix/daemon.cc @@ -210,9 +210,9 @@ static PeerInfo getPeerInfo(int remote) #elif defined(LOCAL_PEERCRED) -#if !defined(SOL_LOCAL) -#define SOL_LOCAL 0 -#endif +# if !defined(SOL_LOCAL) +# define SOL_LOCAL 0 +# endif xucred cred; socklen_t credLen = sizeof(cred); From d8c86ee2c45fb9e8124d946e283fd662ada8c3a8 Mon Sep 17 00:00:00 2001 From: kn Date: Sat, 11 Mar 2023 19:43:04 +0000 Subject: [PATCH 2/2] Use proper struct sockpeercred for SO_PEERCRED for OpenBSD getsockopt(2) documents this; ucred is wrong ("cr_" member prefix, no pid). (cherry picked from commit 10ccdb7a415aec754dc7f834c5f9944c13241473) --- src/nix/daemon.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nix/daemon.cc b/src/nix/daemon.cc index 9ab7d15a3..7e2a9661b 100644 --- a/src/nix/daemon.cc +++ b/src/nix/daemon.cc @@ -202,7 +202,11 @@ static PeerInfo getPeerInfo(int remote) #if defined(SO_PEERCRED) - ucred cred; +# if defined(__OpenBSD__) + struct sockpeercred cred; +# else + ucred cred; +# endif socklen_t credLen = sizeof(cred); if (getsockopt(remote, SOL_SOCKET, SO_PEERCRED, &cred, &credLen) == -1) throw SysError("getting peer credentials");