diff options
author | Slobodan Vrkacevic <slobodan@froglogic.com> | 2016-05-04 14:31:00 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2016-05-18 03:09:55 +0000 |
commit | 80a655749ffbce4ec6328541e194e08d60b34639 (patch) | |
tree | f18b915a6ca62e2708cb825d3d931a02d1268b4b | |
parent | 32ecf4e576e60fd1e411b1e0cec2900516ccbace (diff) |
Make usage of authorization fallback optional
Asking users to use the authorization fallback in case of authorization errors
might be a bit problematic in some cases. If the users are not familiar with the
concept, running: "<installer_exe> --startserver PRODUCTION,{GUID},{GUID}" from
command line might be confusing or difficult. Also it might not help at all.
So let's make this optional. If the config variable DisableAuthorizationFallback
is set to true the installer will not ask users to run the authorization
fallback but instead it will abort the installation immediately.
In RemoteClient this is implemented by adding a new function called
setAuthorizationFallbackDisabled. The init function could be also extend for
this but the config settings are not loaded at the time when the function is
called.
Change-Id: I4baf1dea34c5cc0016e98df47a9492ee1418c5ee
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
-rw-r--r-- | doc/installerfw.qdoc | 4 | ||||
-rw-r--r-- | src/libs/installer/constants.h | 1 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/remoteclient.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/remoteclient.h | 1 | ||||
-rw-r--r-- | src/libs/installer/remoteclient_p.h | 17 | ||||
-rw-r--r-- | src/libs/installer/settings.cpp | 8 | ||||
-rw-r--r-- | src/libs/installer/settings.h | 1 | ||||
-rw-r--r-- | tests/auto/installer/settings/data/full_config.xml | 1 | ||||
-rw-r--r-- | tests/auto/installer/settings/tst_settings.cpp | 1 |
10 files changed, 41 insertions, 1 deletions
diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc index 196fbab10..7a667f912 100644 --- a/doc/installerfw.qdoc +++ b/doc/installerfw.qdoc @@ -282,6 +282,10 @@ \li Set to \c true if the installation path can contain non-ASCII characters. \row + \li DisableAuthorizationFallback + \li Set to \c true if the installation should not ask users to run the authorization + fallback in case of authorization errors. Instead abort the installation immediately. + \row \li RepositorySettingsPageVisible \li Set to \c false to hide the repository settings page inside the settings dialog. \row diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h index 1cba6d572..b871e6209 100644 --- a/src/libs/installer/constants.h +++ b/src/libs/installer/constants.h @@ -81,6 +81,7 @@ static const QLatin1String scRemoveTargetDir("RemoveTargetDir"); static const QLatin1String scRunProgramDescription("RunProgramDescription"); static const QLatin1String scTargetConfigurationFile("TargetConfigurationFile"); static const QLatin1String scAllowNonAsciiCharacters("AllowNonAsciiCharacters"); +static const QLatin1String scDisableAuthorizationFallback("DisableAuthorizationFallback"); static const QLatin1String scRepositorySettingsPageVisible("RepositorySettingsPageVisible"); static const QLatin1String scAllowSpaceInPath("AllowSpaceInPath"); static const QLatin1String scWizardStyle("WizardStyle"); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index af517da5b..492920efc 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -854,6 +854,8 @@ PackageManagerCore::PackageManagerCore(qint64 magicmaker, const QList<OperationB d->initialize(QHash<QString, QString>()); + RemoteClient::instance().setAuthorizationFallbackDisabled(settings().disableAuthorizationFallback()); + // // Sanity check to detect a broken installations with missing operations. // Every installed package should have at least one MinimalProgress operation. diff --git a/src/libs/installer/remoteclient.cpp b/src/libs/installer/remoteclient.cpp index 59a236635..275d8308b 100644 --- a/src/libs/installer/remoteclient.cpp +++ b/src/libs/installer/remoteclient.cpp @@ -77,6 +77,12 @@ void RemoteClient::init(const QString &socketName, const QString &key, Protocol: d->init(socketName, key, mode, startAs); } +void RemoteClient::setAuthorizationFallbackDisabled(bool disabled) +{ + Q_D(RemoteClient); + d->setAuthorizationFallbackDisabled(disabled); +} + void RemoteClient::shutdown() { Q_D(RemoteClient); diff --git a/src/libs/installer/remoteclient.h b/src/libs/installer/remoteclient.h index 278132ba8..f8a87aece 100644 --- a/src/libs/installer/remoteclient.h +++ b/src/libs/installer/remoteclient.h @@ -52,6 +52,7 @@ public: static RemoteClient &instance(); void init(const QString &socketName, const QString &key, Protocol::Mode mode, Protocol::StartAs startAs); + void setAuthorizationFallbackDisabled(bool disabled); void shutdown(); void destroy(); diff --git a/src/libs/installer/remoteclient_p.h b/src/libs/installer/remoteclient_p.h index e88d0579d..92dc18bfa 100644 --- a/src/libs/installer/remoteclient_p.h +++ b/src/libs/installer/remoteclient_p.h @@ -64,6 +64,7 @@ public: , m_active(false) , m_key(QLatin1String(Protocol::DefaultAuthorizationKey)) , m_mode(Protocol::Mode::Debug) + , m_authorizationFallbackDisabled(false) { m_thread.setObjectName(QLatin1String("KeepAlive")); } @@ -106,6 +107,11 @@ public: } } + void setAuthorizationFallbackDisabled(bool disabled) + { + m_authorizationFallbackDisabled = disabled; + } + void maybeStartServer() { if (m_mode == Protocol::Mode::Debug) m_serverStarted = true; // we expect the server to be started by the developer @@ -123,6 +129,16 @@ public: started = AdminAuthorization::execute(0, m_serverCommand, m_serverArguments); if (!started) { + if (m_authorizationFallbackDisabled) { + MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), + QLatin1String("AuthorizationError"), + QCoreApplication::translate("RemoteClient", "Cannot get authorization."), + QCoreApplication::translate("RemoteClient", + "Cannot get authorization that is needed for continuing the installation.\n\n" + "Please start the setup program as a user with the appropriate rights.\n" + "Or accept the elevation of access rights if being asked.")); + return; + } // something went wrong with authorizing, either user pressed cancel or entered // wrong password const QString fallback = m_serverCommand + QLatin1String(" ") + m_serverArguments @@ -184,6 +200,7 @@ private: QString m_key; QThread m_thread; Protocol::Mode m_mode; + bool m_authorizationFallbackDisabled; }; } // namespace QInstaller diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp index 3f0845649..3e933574d 100644 --- a/src/libs/installer/settings.cpp +++ b/src/libs/installer/settings.cpp @@ -256,7 +256,8 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix, << scStartMenuDir << scMaintenanceToolName << scMaintenanceToolIniFile << scRemoveTargetDir << scRunProgram << scRunProgramArguments << scRunProgramDescription << scDependsOnLocalInstallerBinary - << scAllowSpaceInPath << scAllowNonAsciiCharacters << scWizardStyle << scStyleSheet << scTitleColor + << scAllowSpaceInPath << scAllowNonAsciiCharacters << scDisableAuthorizationFallback + << scWizardStyle << scStyleSheet << scTitleColor << scWizardDefaultWidth << scWizardDefaultHeight << scRepositorySettingsPageVisible << scTargetConfigurationFile << scRemoteRepositories << scTranslations << scUrlQueryString << QLatin1String(scControlScript) @@ -520,6 +521,11 @@ bool Settings::allowNonAsciiCharacters() const return d->m_data.value(scAllowNonAsciiCharacters, false).toBool(); } +bool Settings::disableAuthorizationFallback() const +{ + return d->m_data.value(scDisableAuthorizationFallback, false).toBool(); +} + bool Settings::dependsOnLocalInstallerBinary() const { return d->m_data.value(scDependsOnLocalInstallerBinary).toBool(); diff --git a/src/libs/installer/settings.h b/src/libs/installer/settings.h index 9171ff6ae..6c437a72d 100644 --- a/src/libs/installer/settings.h +++ b/src/libs/installer/settings.h @@ -134,6 +134,7 @@ public: bool allowSpaceInPath() const; bool allowNonAsciiCharacters() const; + bool disableAuthorizationFallback() const; bool containsValue(const QString &key) const; QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const; diff --git a/tests/auto/installer/settings/data/full_config.xml b/tests/auto/installer/settings/data/full_config.xml index 5479fa353..1544961f5 100644 --- a/tests/auto/installer/settings/data/full_config.xml +++ b/tests/auto/installer/settings/data/full_config.xml @@ -37,6 +37,7 @@ File should contain all elements we allow in a config.xml <DependsOnLocalInstallerBinary>true</DependsOnLocalInstallerBinary> <AllowSpaceInPath>true</AllowSpaceInPath> <AllowNonAsciiCharacters>true</AllowNonAsciiCharacters> + <DisableAuthorizationFallback>true</DisableAuthorizationFallback> <RepositorySettingsPageVisible>false</RepositorySettingsPageVisible> <CreateLocalRepository>false</CreateLocalRepository> <TargetConfigurationFile>components.xml</TargetConfigurationFile> diff --git a/tests/auto/installer/settings/tst_settings.cpp b/tests/auto/installer/settings/tst_settings.cpp index 38855dccf..0b1987b3d 100644 --- a/tests/auto/installer/settings/tst_settings.cpp +++ b/tests/auto/installer/settings/tst_settings.cpp @@ -74,6 +74,7 @@ void tst_Settings::loadTutorialConfig() QCOMPARE(settings.repositorySettingsPageVisible(), true); QCOMPARE(settings.allowSpaceInPath(), true); QCOMPARE(settings.allowNonAsciiCharacters(), false); + QCOMPARE(settings.disableAuthorizationFallback(), false); QCOMPARE(settings.createLocalRepository(), false); QCOMPARE(settings.installActionColumnVisible(), false); |