diff options
Diffstat (limited to 'tdesu/client.cpp')
| -rw-r--r-- | tdesu/client.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tdesu/client.cpp b/tdesu/client.cpp index c82137cae..54ba1dc00 100644 --- a/tdesu/client.cpp +++ b/tdesu/client.cpp @@ -1,4 +1,4 @@ -/* vi: ts=8 sts=4 sw=4 +/* * * $Id$ * @@ -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> @@ -31,7 +34,7 @@ #include <tqregexp.h> #include <kdebug.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tdeapplication.h> #include <kde_file.h> @@ -50,7 +53,7 @@ public: TDEsuClient::TDEsuClient() { sockfd = -1; -#ifdef Q_WS_X11 +#ifdef TQ_WS_X11 TQCString display(getenv("DISPLAY")); if (display.isEmpty()) { @@ -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); @@ -429,7 +447,7 @@ int TDEsuClient::startServer() // connections. // We start it via tdeinit to make sure that it doesn't inherit // any fd's from the parent process. - int ret = kapp->tdeinitExecWait(d->daemon); + int ret = tdeApp->tdeinitExecWait(d->daemon); connect(); return ret; } |
