summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/packagemanagercore.cpp21
-rw-r--r--src/libs/installer/packagemanagercore.h3
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp2
-rw-r--r--src/libs/installer/packagemanagercore_p.h1
-rw-r--r--src/sdk/installerbase.cpp4
5 files changed, 30 insertions, 1 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 416e91541..74943f913 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -2172,6 +2172,11 @@ Settings &PackageManagerCore::settings() const
*/
bool PackageManagerCore::gainAdminRights()
{
+ if (isCommandLineInstance()) {
+ throw Error(tr("Cannot elevate access rights while running from command line. "
+ "Please restart the application as administrator."));
+ }
+
if (AdminAuthorization::hasAdminRights())
return true;
@@ -2763,6 +2768,22 @@ bool PackageManagerCore::isPackageManager() const
}
/*!
+ Set to use command line instance based on \a commandLineInstance.
+*/
+void PackageManagerCore::setCommandLineInstance(bool commandLineInstance)
+{
+ d->m_commandLineInstance = commandLineInstance;
+}
+
+/*!
+ Returns \c true if running as command line instance.
+*/
+bool PackageManagerCore::isCommandLineInstance() const
+{
+ return d->m_commandLineInstance;
+}
+
+/*!
Returns \c true if it is a package manager or an updater.
*/
bool PackageManagerCore::isMaintainer() const
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index f07fa3a7c..4451e63c2 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -234,6 +234,9 @@ public:
Q_INVOKABLE void setPackageManager();
Q_INVOKABLE bool isPackageManager() const;
+ void setCommandLineInstance(bool commandLineInstance);
+ Q_INVOKABLE bool isCommandLineInstance() const;
+
bool isMaintainer() const;
bool isVerbose() const;
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index f990a1907..e7a97d772 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -216,6 +216,7 @@ PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core)
, m_guiObject(nullptr)
, m_remoteFileEngineHandler(nullptr)
, m_foundEssentialUpdate(false)
+ , m_commandLineInstance(false)
{
}
@@ -247,6 +248,7 @@ PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core, q
, m_guiObject(nullptr)
, m_remoteFileEngineHandler(new RemoteFileEngineHandler)
, m_foundEssentialUpdate(false)
+ , m_commandLineInstance(false)
{
foreach (const OperationBlob &operation, performedOperations) {
QScopedPointer<QInstaller::Operation> op(KDUpdater::UpdateOperationFactory::instance()
diff --git a/src/libs/installer/packagemanagercore_p.h b/src/libs/installer/packagemanagercore_p.h
index f5242f122..c9dfde242 100644
--- a/src/libs/installer/packagemanagercore_p.h
+++ b/src/libs/installer/packagemanagercore_p.h
@@ -186,6 +186,7 @@ public:
bool m_needsHardRestart;
bool m_testChecksum;
bool m_launchedAsRoot;
+ bool m_commandLineInstance;
bool m_completeUninstall;
bool m_needToWriteMaintenanceTool;
PackageManagerCoreData m_data;
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp
index 320a247a2..b1b0e9e5d 100644
--- a/src/sdk/installerbase.cpp
+++ b/src/sdk/installerbase.cpp
@@ -314,7 +314,8 @@ int InstallerBase::run()
}
}
- //Do not show gui with --silentUpdate, instead update components silently
+ // Do not show gui if any of the following options are set
+ m_core->setCommandLineInstance(true);
if (parser.isSet(QLatin1String(CommandLineOptions::SilentUpdate))) {
if (m_core->isInstaller())
throw QInstaller::Error(QLatin1String("Cannot start installer binary as updater."));
@@ -363,6 +364,7 @@ int InstallerBase::run()
return EXIT_FAILURE;
m_core->installDefaultComponentsSilently();
} else {
+ m_core->setCommandLineInstance(false);
//create the wizard GUI
TabController controller(nullptr);
controller.setManager(m_core);