From e5acdb1b39fa7d97d7153741202709e078b463a6 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 --- tdesu/client.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tdesu') diff --git a/tdesu/client.cpp b/tdesu/client.cpp index fe5733ee7..8c775bbed 100644 --- a/tdesu/client.cpp +++ b/tdesu/client.cpp @@ -19,6 +19,9 @@ #include #include #include +#ifdef HAVE_UCRED_H +#include +#endif /* HAVE_UCRED_H */ #include #include @@ -146,6 +149,21 @@ int TDEsuClient::connect() return -1; } # endif +#elif defined(HAVE_GETPEERUCRED) + ucred_t *cred = nullptr; + + if (getpeerucred(sockfd, &cred) == 0) { + uid_t peer_uid = ucred_geteuid(cred); + + ucred_free(cred); + if (peer_uid != getuid()) { + kdWarning(900) << "socket not owned by me! socket uid = " << peer_uid << endl; + close(sockfd); sockfd = -1; + return -1; + } + } + if (cred != nullptr) + ucred_free(cred); #else struct ucred cred; socklen_t siz = sizeof(cred); -- cgit v1.2.1