Skip to content

Commit

Permalink
Merge pull request NixOS#11022 from obsidiansystems/fix-openbsd-socke…
Browse files Browse the repository at this point in the history
…t-peercred

Use proper struct sockpeercred for SO_PEERCRED for OpenBSD
  • Loading branch information
Ericson2314 authored Jul 3, 2024
2 parents 30de61f + 10ccdb7 commit 509be0e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/nix/unix/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,21 @@ 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");
peer = { true, cred.pid, true, cred.uid, true, cred.gid };

#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);
Expand Down

0 comments on commit 509be0e

Please sign in to comment.