Don't terminate the core due to backend issues while setting up
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 30 Aug 2017 21:50:54 +0000 (23:50 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 30 Aug 2017 21:55:25 +0000 (23:55 +0200)
If the authenticator or storage backend selected by the user during
core setup cannot be initialized, the problem shall be communicated
to the client and the user can start over; the core shall not exit
in this case. Ensure that failure to initialize the selected backends
only terminates the core if it's not being setup.

src/core/core.cpp

index 889d15a..d613e8f 100644 (file)
@@ -403,10 +403,15 @@ bool Core::initStorage(const QString &backend, const QVariantMap &settings, bool
             return false;  // trigger setup process
         if (storage->setup(settings))
             return initStorage(backend, settings, false);
             return false;  // trigger setup process
         if (storage->setup(settings))
             return initStorage(backend, settings, false);
+        return false;
+
     // if initialization wasn't successful, we quit to keep from coming up unconfigured
     case Storage::NotAvailable:
         qCritical() << "FATAL: Selected storage backend is not available:" << backend;
     // if initialization wasn't successful, we quit to keep from coming up unconfigured
     case Storage::NotAvailable:
         qCritical() << "FATAL: Selected storage backend is not available:" << backend;
-        exit(EXIT_FAILURE);
+        if (!setup)
+            exit(EXIT_FAILURE);
+        return false;
+
     case Storage::IsReady:
         // delete all other backends
         _registeredStorageBackends.clear();
     case Storage::IsReady:
         // delete all other backends
         _registeredStorageBackends.clear();
@@ -495,10 +500,15 @@ bool Core::initAuthenticator(const QString &backend, const QVariantMap &settings
             return false;  // trigger setup process
         if (auth->setup(settings))
             return initAuthenticator(backend, settings, false);
             return false;  // trigger setup process
         if (auth->setup(settings))
             return initAuthenticator(backend, settings, false);
+        return false;
+
     // if initialization wasn't successful, we quit to keep from coming up unconfigured
     case Authenticator::NotAvailable:
         qCritical() << "FATAL: Selected auth backend is not available:" << backend;
     // if initialization wasn't successful, we quit to keep from coming up unconfigured
     case Authenticator::NotAvailable:
         qCritical() << "FATAL: Selected auth backend is not available:" << backend;
-        exit(EXIT_FAILURE);
+        if (!setup)
+            exit(EXIT_FAILURE);
+        return false;
+
     case Authenticator::IsReady:
         // delete all other backends
         _registeredAuthenticators.clear();
     case Authenticator::IsReady:
         // delete all other backends
         _registeredAuthenticators.clear();