event/ServerSocket: use SocketDescriptor::GetPeerCredentials()

This commit is contained in:
Max Kellermann
2025-01-29 17:53:45 +01:00
parent 3710b54d43
commit 4bb379a218

View File

@@ -105,10 +105,8 @@ static int
get_remote_uid(SocketDescriptor s) noexcept get_remote_uid(SocketDescriptor s) noexcept
{ {
#ifdef HAVE_STRUCT_UCRED #ifdef HAVE_STRUCT_UCRED
struct ucred cred; const auto cred = s.GetPeerCredentials();
socklen_t len = sizeof (cred); if (cred.pid < 0)
if (getsockopt(s.Get(), SOL_SOCKET, SO_PEERCRED, &cred, &len) < 0)
return -1; return -1;
return cred.uid; return cred.uid;