From 227cd7b44beb0949be8d8186899c91f2fc08ba59 Mon Sep 17 00:00:00 2001 From: Denis Kozadaev Date: Sun, 14 May 2023 12:34:44 +0300 Subject: Add SunOS specific patches Signed-off-by: Denis Kozadaev (cherry picked from commit e5acdb1b39fa7d97d7153741202709e078b463a6) --- dcop/dcopclient.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'dcop') diff --git a/dcop/dcopclient.cpp b/dcop/dcopclient.cpp index 5523365c8..52d9097c1 100644 --- a/dcop/dcopclient.cpp +++ b/dcop/dcopclient.cpp @@ -50,6 +50,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#ifdef HAVE_UCRED_H +#include +#endif /* HAVE_UCRED_H */ #include #include @@ -724,7 +727,7 @@ bool DCOPClient::isSuspended() const return !d->notifier->isEnabled(); } -#if defined(SO_PEERCRED) || defined(LOCAL_PEEREID) +#if defined(SO_PEERCRED) || defined(LOCAL_PEEREID) || defined(HAVE_GETPEERUCRED) #define USE_PEER_IS_US // Check whether the remote end is owned by the same user. static bool peerIsUs(int sockfd) @@ -745,6 +748,18 @@ static bool peerIsUs(int sockfd) if (getsockopt(sockfd, 0, LOCAL_PEEREID, &cred, &siz) != 0 || siz != sizeof(cred)) return false; return (cred.unp_euid == geteuid()); +#elif defined(HAVE_GETPEERUCRED) + ucred_t *cred = nullptr; + uint_t peer_uid; + + if (getpeerucred(sockfd, &cred) != 0) { + if (cred != nullptr) + ucred_free(cred); + return false; + } + peer_uid = ucred_geteuid(cred); + ucred_free(cred); + return (peer_uid == getuid()); #endif } #else -- cgit v1.2.1