diff options
Diffstat (limited to 'dcop/dcopclient.cpp')
| -rw-r--r-- | dcop/dcopclient.cpp | 82 |
1 files changed, 60 insertions, 22 deletions
diff --git a/dcop/dcopclient.cpp b/dcop/dcopclient.cpp index 7c884fe46..1533b802c 100644 --- a/dcop/dcopclient.cpp +++ b/dcop/dcopclient.cpp @@ -41,6 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <sys/stat.h> #include <sys/file.h> #include <sys/socket.h> +#include <sys/un.h> #include <fcntl.h> #include <unistd.h> @@ -49,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> @@ -58,13 +62,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <tqsocketnotifier.h> #include <tqregexp.h> -#include <tqucomextra_p.h> +#include <private/tqucomextra_p.h> #include <dcopglobal.h> #include <dcopclient.h> #include <dcopobject.h> -#if defined Q_WS_X11 && ! defined K_WS_QTONLY +#if defined TQ_WS_X11 && ! defined K_WS_QTONLY #include <X11/Xmd.h> #endif extern "C" { @@ -209,13 +213,26 @@ public: TQCString DCOPClient::iceauthPath() { -#ifdef Q_OS_WIN32 +#if defined(ICEAUTH_PATH) + if ( +# if defined(TQ_WS_WIN) + access(ICEAUTH_PATH, 0) == 0 +# else + access(ICEAUTH_PATH, X_OK) == 0 +# endif + ) + { + return TQCString(ICEAUTH_PATH); + } + +#elif defined(Q_OS_WIN32) char szPath[512]; char * pszFilePart; int ret; ret = SearchPathA(NULL,"iceauth.exe",NULL,sizeof(szPath)/sizeof(szPath[0]),szPath,&pszFilePart); if(ret != 0) return TQCString(szPath); + #else TQCString path = ::getenv("PATH"); if (path.isEmpty()) @@ -229,9 +246,9 @@ TQCString DCOPClient::iceauthPath() { return fPath; } - fPath = strtok(NULL, ":\b"); } + #endif return 0; } @@ -249,9 +266,9 @@ static TQCString dcopServerFile(const TQCString &hostname, bool old) fprintf(stderr, "Aborting. $HOME is not set.\n"); exit(1); } -#ifdef Q_WS_X11 +#ifdef TQ_WS_X11 TQCString disp = getenv("DISPLAY"); -#elif defined(Q_WS_QWS) +#elif defined(TQ_WS_QWS) TQCString disp = getenv("QWS_DISPLAY"); #else TQCString disp; @@ -317,10 +334,10 @@ void DCOPClient::handleAsyncReply(ReplyStruct *replyStruct) { if (replyStruct->replyObject) { - TQObject::connect(this, TQT_SIGNAL(callBack(int, const TQCString&, const TQByteArray &)), + TQObject::connect(this, TQ_SIGNAL(callBack(int, const TQCString&, const TQByteArray &)), replyStruct->replyObject, replyStruct->replySlot); emit callBack(replyStruct->replyId, *(replyStruct->replyType), *(replyStruct->replyData)); - TQObject::disconnect(this, TQT_SIGNAL(callBack(int, const TQCString&, const TQByteArray &)), + TQObject::disconnect(this, TQ_SIGNAL(callBack(int, const TQCString&, const TQByteArray &)), replyStruct->replyObject, replyStruct->replySlot); } delete replyStruct; @@ -422,9 +439,9 @@ static void DCOPProcessMessage(IceConn iceConn, IcePointer clientObject, return; } } + tqWarning("Very strange! got a DCOPReplyDelayed opcode, but we were not waiting for a reply!"); + return; } - tqWarning("Very strange! got a DCOPReplyDelayed opcode, but we were not waiting for a reply!"); - return; case DCOPCall: case DCOPFind: case DCOPSend: @@ -608,8 +625,8 @@ DCOPClient::DCOPClient() d->qt_bridge_enabled = true; d->transactionList = 0L; d->transactionId = 0; - TQObject::connect( &d->postMessageTimer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( processPostedMessagesInternal() ) ); - TQObject::connect( &d->eventLoopTimer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( eventLoopTimeout() ) ); + TQObject::connect( &d->postMessageTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( processPostedMessagesInternal() ) ); + TQObject::connect( &d->eventLoopTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( eventLoopTimeout() ) ); if ( !mainClient() ) setMainClient( this ); @@ -676,14 +693,14 @@ void DCOPClient::bindToApp() delete d->notifier; d->notifier = new TQSocketNotifier(socket(), TQSocketNotifier::Read, 0, 0); - TQObject::connect(d->notifier, TQT_SIGNAL(activated(int)), - TQT_SLOT(processSocketData(int))); + TQObject::connect(d->notifier, TQ_SIGNAL(activated(int)), + TQ_SLOT(processSocketData(int))); } } void DCOPClient::suspend() { -#ifdef Q_WS_WIN //TODO: remove (win32 ports sometimes do not create notifiers) +#ifdef TQ_WS_WIN //TODO: remove (win32 ports sometimes do not create notifiers) if (!d->notifier) return; #endif @@ -693,7 +710,7 @@ void DCOPClient::suspend() void DCOPClient::resume() { -#ifdef Q_WS_WIN //TODO: remove +#ifdef TQ_WS_WIN //TODO: remove if (!d->notifier) return; #endif @@ -703,17 +720,19 @@ void DCOPClient::resume() bool DCOPClient::isSuspended() const { -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) //TODO: REMOVE +#if defined(TQ_WS_WIN) || defined(TQ_WS_MAC) //TODO: REMOVE if (!d->notifier) return false; #endif return !d->notifier->isEnabled(); } -#ifdef SO_PEERCRED +#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) { +#ifdef SO_PEERCRED #if defined(__OpenBSD__) struct sockpeercred cred; #else @@ -723,6 +742,25 @@ static bool peerIsUs(int sockfd) if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &cred, &siz) != 0) return false; 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()); +#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 // Check whether the socket is owned by the same user. @@ -783,7 +821,7 @@ bool DCOPClient::attachInternal( bool registerAsAnonymous ) emit attachFailed(TQString::fromLatin1( "Could not read network connection list.\n" )+TQFile::decodeName(fName)); return false; } - int size = TQMIN( (qint64)1024, f.size() ); // protection against a huge file + int size = TQMIN( (long)1024, f.size() ); // protection against a huge file TQCString contents( size+1 ); if ( f.readBlock( contents.data(), size ) != size ) { @@ -868,7 +906,7 @@ bool DCOPClient::attachInternal( bool registerAsAnonymous ) return false; } -#ifdef SO_PEERCRED +#ifdef USE_PEER_IS_US d->foreign_server = !peerIsUs(socket()); #else d->foreign_server = !isServerSocketOwnedByUser(d->serverAddr); @@ -1474,7 +1512,7 @@ static bool receiveQtObject( const TQCString &objId, const TQCString &fun, const TQStrList lst = o->metaObject()->slotNames( true ); int i = 0; for ( TQPtrListIterator<char> it( lst ); it.current(); ++it ) { - if ( o->metaObject()->slot( i++, true )->tqt_mo_access != TQMetaData::Public ) + if ( o->metaObject()->slot( i++, true )->access != TQMetaData::Public ) continue; TQCString slot = it.current(); if ( slot.contains( "()" ) ) { @@ -1818,7 +1856,7 @@ int DCOPClient::callAsync(const TQCString &remApp, const TQCString &remObjId, if (replyStruct->transactionId == 0) { // Call is finished already - TQTimer::singleShot(0, this, TQT_SLOT(asyncReplyReady())); + TQTimer::singleShot(0, this, TQ_SLOT(asyncReplyReady())); d->asyncReplyQueue.append(replyStruct); } |
