From cdd1c8d0d9f336bae11074cf475f855929171df4 Mon Sep 17 00:00:00 2001 From: nipos Date: Sat, 25 Feb 2023 18:58:53 +0100 Subject: [PATCH] LibCore: Implement socket credentials for Solaris --- Userland/Libraries/LibCore/Socket.cpp | 6 ++++++ Userland/Libraries/LibCore/System.h | 1 + 2 files changed, 7 insertions(+) diff --git a/Userland/Libraries/LibCore/Socket.cpp b/Userland/Libraries/LibCore/Socket.cpp index c6be2ad77ce..dfc400322fa 100644 --- a/Userland/Libraries/LibCore/Socket.cpp +++ b/Userland/Libraries/LibCore/Socket.cpp @@ -370,6 +370,9 @@ ErrorOr LocalSocket::peer_pid() const #elif defined(AK_OS_NETBSD) struct sockcred creds = {}; socklen_t creds_size = sizeof(creds); +#elif defined(AK_OS_SOLARIS) + ucred_t* creds = NULL; + socklen_t creds_size = sizeof(creds); #else struct ucred creds = {}; socklen_t creds_size = sizeof(creds); @@ -384,6 +387,9 @@ ErrorOr LocalSocket::peer_pid() const #elif defined(AK_OS_NETBSD) TRY(System::getsockopt(m_helper.fd(), SOL_SOCKET, SCM_CREDS, &creds, &creds_size)); return creds.sc_pid; +#elif defined(AK_OS_SOLARIS) + TRY(System::getsockopt(m_helper.fd(), SOL_SOCKET, SO_RECVUCRED, &creds, &creds_size)); + return ucred_getpid(creds); #else TRY(System::getsockopt(m_helper.fd(), SOL_SOCKET, SO_PEERCRED, &creds, &creds_size)); return creds.pid; diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index ea00998ac77..785ea92e9c7 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -37,6 +37,7 @@ #ifdef AK_OS_SOLARIS # include +# include #endif namespace Core::System {