summaryrefslogtreecommitdiffstats
path: root/tdesu/client.cpp
diff options
context:
space:
mode:
authorDenis Kozadaev <[email protected]>2023-05-14 12:34:44 +0300
committerMichele Calgaro <[email protected]>2023-05-22 10:47:39 +0900
commit227cd7b44beb0949be8d8186899c91f2fc08ba59 (patch)
treeaa43141f354cb72e1fd394b8e64a96906e1dc9cd /tdesu/client.cpp
parentb7a4d45c14908b542b91976b71f0d51e785f9006 (diff)
downloadtdelibs-227cd7b44beb0949be8d8186899c91f2fc08ba59.tar.gz
tdelibs-227cd7b44beb0949be8d8186899c91f2fc08ba59.zip
Add SunOS specific patches
Signed-off-by: Denis Kozadaev <[email protected]> (cherry picked from commit e5acdb1b39fa7d97d7153741202709e078b463a6)
Diffstat (limited to 'tdesu/client.cpp')
-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);