summaryrefslogtreecommitdiffstats
path: root/tdesu
diff options
context:
space:
mode:
authorDenis Kozadaev <[email protected]>2023-05-14 12:34:44 +0300
committerMichele Calgaro <[email protected]>2023-05-22 10:41:26 +0900
commite5acdb1b39fa7d97d7153741202709e078b463a6 (patch)
tree8fdda91a64ae0c7f35474d44e29139f38f297958 /tdesu
parent394b5ef0fb0e0555d16bced7c4c2c1b2ac1a8463 (diff)
downloadtdelibs-e5acdb1b39fa7d97d7153741202709e078b463a6.tar.gz
tdelibs-e5acdb1b39fa7d97d7153741202709e078b463a6.zip
Add SunOS specific patches
Signed-off-by: Denis Kozadaev <[email protected]>
Diffstat (limited to 'tdesu')
-rw-r--r--tdesu/client.cpp18
1 files changed, 18 insertions, 0 deletions
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 <pwd.h>
#include <errno.h>
#include <string.h>
+#ifdef HAVE_UCRED_H
+#include <ucred.h>
+#endif /* HAVE_UCRED_H */
#include <sys/types.h>
#include <sys/socket.h>
@@ -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);