summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobert Obermeier <obermert@iis.fraunhofer.de>2017-05-10 14:20:04 +0200
committerKatja Marttila <katja.marttila@qt.io>2017-06-15 05:03:54 +0000
commitee435ce9227a3b87e1d29f098f72cb2a2ad6e6c0 (patch)
treeb1dd74b006962610ab3ac236f552c71220e0b4cf /src
parent67d17514707edda2341f11a09a6b22a0c506443a (diff)
Adminauthorization freeze fixed under unix
This should fix x11 authorization livelock problems causing the installer to freeze after password entry. There might be unrelated issues causeing further freezes. Further explanation: If sudo does not terminate then closing stderr has no effect in remoteserver.cpp and the loop in adminauthorization_x11.cpp reading from pipedData will never terminate, causing the installer to freeze. It is important to close all references to stderr and terminate all applications that do not close stderr themselves in the fork/exec chain from adminauthorization_x11.cpp up to the remoteserver. Remoteserver will close stderr in remoteserver.cpp. Forking is done in main cause we can arrange it so that no threads are running up to this point. If any thread were running we would need to fork/exec in the child to be sure to restore a semi-deterministic state. Task-number: QTIFW-934 Change-Id: I87374d3ff195b42da0248c83aff020d373306d93 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/sdk/main.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/sdk/main.cpp b/src/sdk/main.cpp
index 78d24ea70..70c675f91 100644
--- a/src/sdk/main.cpp
+++ b/src/sdk/main.cpp
@@ -44,7 +44,7 @@
#include <iostream>
-#if defined(Q_OS_OSX)
+#if defined(Q_OS_OSX) or defined(Q_OS_UNIX)
# include <unistd.h>
# include <sys/types.h>
#endif
@@ -133,8 +133,24 @@ int main(int argc, char *argv[])
const bool production = (mode.compare(QLatin1String(QInstaller::Protocol::ModeProduction),
Qt::CaseInsensitive) == 0);
- if (production)
+ if (production) {
argumentsValid = (!key.isEmpty()) && (!socketName.isEmpty());
+#if defined(Q_OS_UNIX) && !defined(Q_OS_OSX)
+ /* In production mode detach child so that sudo waiting on us will terminate. */
+ pid_t child = fork();
+ if (child <= -1) {
+ std::cerr << "Fatal cannot fork and detach server." << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ if (child != 0) {
+ return EXIT_SUCCESS;
+ }
+
+ ::setsid();
+#endif
+ }
+
SDKApp<QCoreApplication> app(argc, argv);
if (!argumentsValid) {