summaryrefslogtreecommitdiffstats
path: root/src/input/pvsPrivInputSocket.cpp
diff options
context:
space:
mode:
authorSebastien Braun2010-10-06 15:08:03 +0200
committerSebastien Braun2010-10-06 15:08:03 +0200
commit6afd810d1954018791456a7cebca0d275c50ed95 (patch)
tree64d7b3e560dde3049c6c3056387c14f10066c666 /src/input/pvsPrivInputSocket.cpp
parentImplement administratively configured user privileges (diff)
downloadpvs-6afd810d1954018791456a7cebca0d275c50ed95.tar.gz
pvs-6afd810d1954018791456a7cebca0d275c50ed95.tar.xz
pvs-6afd810d1954018791456a7cebca0d275c50ed95.zip
Refactor signal handling in pvsprivinputd
Only use one socketpair and delegate the actual decision of what to do when a specific signal is received to a special object.
Diffstat (limited to 'src/input/pvsPrivInputSocket.cpp')
-rw-r--r--src/input/pvsPrivInputSocket.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/input/pvsPrivInputSocket.cpp b/src/input/pvsPrivInputSocket.cpp
index c491dd9..df5dff5 100644
--- a/src/input/pvsPrivInputSocket.cpp
+++ b/src/input/pvsPrivInputSocket.cpp
@@ -60,6 +60,17 @@ QString pvsPrivInputGetSocketAddress()
return pvsPrivInputGetSettings()->value("socketpath", "/tmp/pvsprivinputd.sock").toString();
}
+bool pvsPrivInputEnableReceiveCredentials(int sock)
+{
+ int passcred = 1;
+ if(setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &passcred, sizeof(passcred)) < 0)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
}
int pvsPrivInputMakeClientSocket()
@@ -110,8 +121,7 @@ int pvsPrivInputMakeServerSocket()
}
// Announce that credentials are requested:
- int passcred = 1;
- if(setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &passcred, sizeof(passcred)) < 0)
+ if(!pvsPrivInputEnableReceiveCredentials(sock))
{
// We will not operate without credentials.
qCritical("Could not request peer credentials: %s", strerror(errno));