summaryrefslogtreecommitdiffstats
path: root/dcop/dcopclient.cpp
diff options
context:
space:
mode:
authorDenis Kozadaev <denis@dilos.org>2023-05-14 12:34:44 +0300
committerMichele Calgaro <michele.calgaro@yahoo.it>2023-05-22 10:47:39 +0900
commit227cd7b44beb0949be8d8186899c91f2fc08ba59 (patch)
treeaa43141f354cb72e1fd394b8e64a96906e1dc9cd /dcop/dcopclient.cpp
parentb7a4d45c14908b542b91976b71f0d51e785f9006 (diff)
downloadtdelibs-227cd7b44beb0949be8d8186899c91f2fc08ba59.tar.gz
tdelibs-227cd7b44beb0949be8d8186899c91f2fc08ba59.zip
Add SunOS specific patches
Signed-off-by: Denis Kozadaev <denis@dilos.org> (cherry picked from commit e5acdb1b39fa7d97d7153741202709e078b463a6)
Diffstat (limited to 'dcop/dcopclient.cpp')
-rw-r--r--dcop/dcopclient.cpp17
1 files changed, 16 insertions, 1 deletions
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 <stdlib.h>
#include <assert.h>
#include <string.h>
+#ifdef HAVE_UCRED_H
+#include <ucred.h>
+#endif /* HAVE_UCRED_H */
#include <tqguardedptr.h>
#include <tqtextstream.h>
@@ -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