I have expected SO_PEERCRED getsockopt to be portable on AF_UNIX. It is #Linux specific. #FreeBSD has something very similar, but slightly different. Incompatible. Would anyone know any shared library for obtaining remote client information on any supported platform?

@pemensik here's how Ladybird does it. Getting peer information is probably the least portable socket operation I've ever seen. Every unix does it slightly differently just for fun.

https://github.com/LadybirdBrowser/ladybird/blob/master/Libraries/LibCore/Socket.cpp#L482-L521

ladybird/Libraries/LibCore/Socket.cpp at master · LadybirdBrowser/ladybird

Truly independent web browser. Contribute to LadybirdBrowser/ladybird development by creating an account on GitHub.

GitHub
@akaster found libsystemd has sort of nice abstraction in sd_pid_get*. Also with sd_peer_* for Unix sockets. But that won't be portable to other Unix systems. Is there other attempt?