Files
Martin VogelandYury Romanov c8de7dcb68 fix(daemon): read the peer pid on FreeBSD via LOCAL_PEERCRED
cbm_daemon_ipc_connection_peer_pid() had branches for Linux
(SO_PEERCRED), macOS (LOCAL_PEERPID) and NetBSD (LOCAL_PEEREID), but
FreeBSD defines none of them, so it fell through to `return 0`, and
runtime_accept_connection() closes every connection whose peer pid is
0: on FreeBSD the daemon rejected every client.

Read the peer credentials with getsockopt(SOL_LOCAL, LOCAL_PEERCRED)
into a struct xucred and accept only the expected layout version, the
caller's effective uid and a positive pid, mirroring the Linux branch.
The branch and its <sys/ucred.h> include compile only on FreeBSD.

Carried forward from #2492, which also raised three timeouts on every
platform; those are left out (CBM_STARTUP_TIMEOUT_MS covers slow hosts).

Co-authored-by: Yury Romanov <romanov@outlook.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-12 20:36:45 +01:00
..