From e61097b8881bc7e72a5499816cb1199ea274a3ca Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Thu, 7 Oct 2010 22:54:10 +0200 Subject: Rework template meta-magic - No more implicit dependency on Boost.MPL - Better documentation for template magic - Move input handler policies to handler definitions where they belong - Separate out event descriptions from handlers --- src/input/pvsPrivInputHandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/input/pvsPrivInputHandler.cpp') diff --git a/src/input/pvsPrivInputHandler.cpp b/src/input/pvsPrivInputHandler.cpp index 70ed1bc..bfa60ce 100644 --- a/src/input/pvsPrivInputHandler.cpp +++ b/src/input/pvsPrivInputHandler.cpp @@ -21,7 +21,7 @@ #include #include #include "inputEvent.h" -#include "inputEventHandler.h" +#include "inputHandlerChains.h" #include "pvsPrivInputSocket.h" #include "pvsPrivInputHandler.h" @@ -63,6 +63,7 @@ PVSPrivInputHandler::PVSPrivInputHandler(int fd, QObject* parent) : _notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); _notifier->setEnabled(true); connect(_notifier, SIGNAL(activated(int)), this, SLOT(canRead())); + _handlerChain = makePrivilegedInputEventHandlerChain(); } PVSPrivInputHandler::~PVSPrivInputHandler() -- cgit v1.2.3-55-g7522 From 18f16ac568d0c699fe24271c5b77f573b749092e Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Sun, 10 Oct 2010 01:40:33 +0200 Subject: Lose the `get' method prefix on InputEventContext since it does not fit in --- src/input/inputEventHandler.h | 6 +++--- src/input/killX11Handler.cpp | 2 +- src/input/pvsCheckPrivileges.h | 6 +++--- src/input/pvsPrivInputHandler.cpp | 6 +++--- src/input/sayHelloHandler.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/input/pvsPrivInputHandler.cpp') diff --git a/src/input/inputEventHandler.h b/src/input/inputEventHandler.h index 71a530b..735b75c 100644 --- a/src/input/inputEventHandler.h +++ b/src/input/inputEventHandler.h @@ -33,9 +33,9 @@ struct InputEventContext hasBeenDenied = false; } - virtual pid_t getSenderPid() const = 0; - virtual uid_t getSenderUid() const = 0; - virtual gid_t getSenderGid() const = 0; + virtual pid_t senderPid() const = 0; + virtual uid_t senderUid() const = 0; + virtual gid_t senderGid() const = 0; mutable bool hasBeenDenied; }; diff --git a/src/input/killX11Handler.cpp b/src/input/killX11Handler.cpp index 572656e..32e5873 100644 --- a/src/input/killX11Handler.cpp +++ b/src/input/killX11Handler.cpp @@ -33,7 +33,7 @@ void KillX11Handler::doHandle(InputEvent const&, InputEventContext const* ctx) if(displayDevice.isNull()) { - qWarning("Can not kill X server for %d,%d,%d: No Display Device", ctx->getSenderPid(), ctx->getSenderUid(), ctx->getSenderGid()); + qWarning("Can not kill X server for %d,%d,%d: No Display Device", ctx->senderPid(), ctx->senderUid(), ctx->senderGid()); return; } diff --git a/src/input/pvsCheckPrivileges.h b/src/input/pvsCheckPrivileges.h index 62b463c..92c68fe 100644 --- a/src/input/pvsCheckPrivileges.h +++ b/src/input/pvsCheckPrivileges.h @@ -32,9 +32,9 @@ struct CachedInputContext { if(source) { - pid = source->getSenderPid(); - uid = source->getSenderUid(); - gid = source->getSenderGid(); + pid = source->senderPid(); + uid = source->senderUid(); + gid = source->senderGid(); } else { diff --git a/src/input/pvsPrivInputHandler.cpp b/src/input/pvsPrivInputHandler.cpp index bfa60ce..84ccbae 100644 --- a/src/input/pvsPrivInputHandler.cpp +++ b/src/input/pvsPrivInputHandler.cpp @@ -35,17 +35,17 @@ public: { } - pid_t getSenderPid() const + pid_t senderPid() const { return _pid; } - uid_t getSenderUid() const + uid_t senderUid() const { return _uid; } - gid_t getSenderGid() const + gid_t senderGid() const { return _gid; } diff --git a/src/input/sayHelloHandler.cpp b/src/input/sayHelloHandler.cpp index 712963d..301709f 100644 --- a/src/input/sayHelloHandler.cpp +++ b/src/input/sayHelloHandler.cpp @@ -21,5 +21,5 @@ using namespace std; void SayHelloHandler::doHandle(InputEvent const&, InputEventContext const* ctx) { - cerr << "I'm right here! You sent this message from pid " << ctx->getSenderPid() << " as user " << ctx->getSenderUid() << " with gid " << ctx->getSenderGid() << endl; + cerr << "I'm right here! You sent this message from pid " << ctx->senderPid() << " as user " << ctx->senderUid() << " with gid " << ctx->senderGid() << endl; } -- cgit v1.2.3-55-g7522 From bcaa6e3580f5b227ab48693192c459cc72c30224 Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Mon, 11 Oct 2010 12:27:27 +0200 Subject: Better error handling for PVSPrivInputHandler --- src/input/pvsPrivInputHandler.cpp | 21 ++++++++++++++++++--- src/input/pvsprivinputd.cpp | 4 +++- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/input/pvsPrivInputHandler.cpp') diff --git a/src/input/pvsPrivInputHandler.cpp b/src/input/pvsPrivInputHandler.cpp index 84ccbae..d33697a 100644 --- a/src/input/pvsPrivInputHandler.cpp +++ b/src/input/pvsPrivInputHandler.cpp @@ -86,9 +86,24 @@ void PVSPrivInputHandler::canRead() if(!pvsPrivInputRecvMessage(_fd, _messageAssembly.data(), siz, pid, uid, gid, &err)) { - close(_fd); - deleteLater(); - return; + switch(err) + { + case EAGAIN: +#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN) + case EWOULDBLOCK: +#endif + // That's okay. Nothing to do. + break; + case 0: + // We'll survive. There was no actual error, just the library routine + // that decided it did not really want to receive that packet. + break; + default: + qWarning("Something bad just happened, and cannot handle it. Panicking."); + close(_fd); + deleteLater(); + return; + } } else { diff --git a/src/input/pvsprivinputd.cpp b/src/input/pvsprivinputd.cpp index e6ae155..df3acfc 100644 --- a/src/input/pvsprivinputd.cpp +++ b/src/input/pvsprivinputd.cpp @@ -182,7 +182,9 @@ int main(int argc, char** argv) } // Install our main object - PVSPrivInputHandler handler(sock); + PVSPrivInputHandler* handler = new PVSPrivInputHandler(sock, &app); + // When the handler gets deleted, we want to quit the application + QObject::connect(handler, SIGNAL(destroyed(QObject*)), &app, SLOT(quit())); // set up signal handling: if(socketpair(AF_UNIX, SOCK_DGRAM, 0, signalFds) < 0) -- cgit v1.2.3-55-g7522