net/PeerCredentials: add getpeereid() support

This commit is contained in:
Max Kellermann
2025-01-29 19:05:10 +01:00
parent c7621ec0e4
commit a0825e6ce0
3 changed files with 22 additions and 8 deletions
-8
View File
@@ -105,19 +105,11 @@ static constexpr Domain server_socket_domain("server_socket");
static int
get_remote_uid(SocketDescriptor s) noexcept
{
#ifdef HAVE_GETPEEREID
uid_t euid;
gid_t egid;
if (getpeereid(s.Get(), &euid, &egid) == 0)
return euid;
#else
const auto cred = s.GetPeerCredentials();
if (!cred.IsDefined())
return -1;
return cred.GetUid();
#endif
}
inline void