diff options
Diffstat (limited to 'dcop')
-rw-r--r-- | dcop/dcopclient.cpp | 17 |
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 |