head 1.1; access; symbols pkgsrc-2026Q1:1.1.0.10 pkgsrc-2026Q1-base:1.1 pkgsrc-2025Q4:1.1.0.8 pkgsrc-2025Q4-base:1.1 pkgsrc-2025Q3:1.1.0.6 pkgsrc-2025Q3-base:1.1 pkgsrc-2025Q2:1.1.0.4 pkgsrc-2025Q2-base:1.1 pkgsrc-2025Q1:1.1.0.2 pkgsrc-2025Q1-base:1.1; locks; strict; comment @// @; 1.1 date 2025.02.07.13.19.30; author riastradh; state Exp; branches; next ; commitid X8ZMj2qsF9navxIF; desc @@ 1.1 log @devel/capnproto: Teach this to get local socket peer creds on NetBSD. @ text @$NetBSD$ Teach capnproto how to get local socket peer identity on NetBSD. Resolves: kj/async-io-test.c++:208: LocalPeerIdentity for unix socket had null UID stack: kj/async-io-test.c++:236: LocalPeerIdentity for unix socket had null UID stack: [ FAIL ] kj/async-io-test.c++:176: legacy test: AsyncIo/UnixSocket (335 μs) --- src/kj/async-io-unix.c++.orig 2024-12-21 15:52:28.000000000 +0000 +++ src/kj/async-io-unix.c++ @@@@ -66,7 +66,7 @@@@ #include #endif -#if !defined(SOL_LOCAL) && (__FreeBSD__ || __DragonflyBSD__ || __APPLE__) +#if !defined(SOL_LOCAL) && (__FreeBSD__ || __DragonflyBSD__ || __NetBSD__ || __APPLE__) // On DragonFly, FreeBSD < 12.2 and older Darwin you're supposed to use 0 for SOL_LOCAL. #define SOL_LOCAL 0 #endif @@@@ -1728,6 +1728,18 @@@@ kj::Own SocketAddress::get result.pid = pid; } #endif + +#elif defined(LOCAL_PEEREID) + // The main public interface is getpeereid(3), but this is more + // convenient to slip in here without threading anything new + // through the AsyncIoStream abstraction. + struct unpcbid creds; + socklen_t length = sizeof(creds); + stream.getsockopt(SOL_LOCAL, LOCAL_PEEREID, &creds, &length); + KJ_ASSERT(length == sizeof(creds)); + if (creds.unp_euid != static_cast(-1)) { + result.uid = creds.unp_euid; + } #endif return LocalPeerIdentity::newInstance(result); @