|
|
@ -41,6 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
|
@ -713,10 +714,12 @@ bool DCOPClient::isSuspended() const
|
|
|
|
return !d->notifier->isEnabled();
|
|
|
|
return !d->notifier->isEnabled();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SO_PEERCRED
|
|
|
|
#if defined(SO_PEERCRED) || defined(LOCAL_PEEREID)
|
|
|
|
|
|
|
|
#define USE_PEER_IS_US
|
|
|
|
// Check whether the remote end is owned by the same user.
|
|
|
|
// Check whether the remote end is owned by the same user.
|
|
|
|
static bool peerIsUs(int sockfd)
|
|
|
|
static bool peerIsUs(int sockfd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef SO_PEERCRED
|
|
|
|
#if defined(__OpenBSD__)
|
|
|
|
#if defined(__OpenBSD__)
|
|
|
|
struct sockpeercred cred;
|
|
|
|
struct sockpeercred cred;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
@ -726,6 +729,13 @@ static bool peerIsUs(int sockfd)
|
|
|
|
if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &cred, &siz) != 0)
|
|
|
|
if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &cred, &siz) != 0)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
return (cred.uid == getuid());
|
|
|
|
return (cred.uid == getuid());
|
|
|
|
|
|
|
|
#elif defined LOCAL_PEEREID
|
|
|
|
|
|
|
|
struct unpcbid cred;
|
|
|
|
|
|
|
|
socklen_t siz = sizeof(cred);
|
|
|
|
|
|
|
|
if (getsockopt(sockfd, 0, LOCAL_PEEREID, &cred, &siz) != 0 || siz != sizeof(cred))
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return (cred.unp_euid == geteuid());
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
// Check whether the socket is owned by the same user.
|
|
|
|
// Check whether the socket is owned by the same user.
|
|
|
@ -871,7 +881,7 @@ bool DCOPClient::attachInternal( bool registerAsAnonymous )
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SO_PEERCRED
|
|
|
|
#ifdef USE_PEER_IS_US
|
|
|
|
d->foreign_server = !peerIsUs(socket());
|
|
|
|
d->foreign_server = !peerIsUs(socket());
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
d->foreign_server = !isServerSocketOwnedByUser(d->serverAddr);
|
|
|
|
d->foreign_server = !isServerSocketOwnedByUser(d->serverAddr);
|
|
|
|