[PATCH 4 of 4] Use sudo to install software in case of is_admin
Wald Commits
scm-commit at wald.intevation.org
Tue Jul 15 16:37:34 CEST 2014
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1405434684 -7200
# Node ID ee75e236843c5ac54470ef66b204fca1057a32ce
# Parent 4b702f6cf9b6a6d301800ee8f0a093d71b8b383b
Use sudo to install software in case of is_admin
diff -r 4b702f6cf9b6 -r ee75e236843c ui/mainwindow.cpp
--- a/ui/mainwindow.cpp Tue Jul 15 16:30:55 2014 +0200
+++ b/ui/mainwindow.cpp Tue Jul 15 16:31:24 2014 +0200
@@ -297,15 +297,30 @@
}
#else /* WIN32 */
QStringList parameters;
- parameters << "/S" << "/UPDATE=1"
- << QString::fromLatin1("/D=%1").arg(installDir.path());
+ parameters << "--prefix" << installDir.path();
+ bool sudo_started = false;
+ bool use_sudo = is_admin();
+ if (use_sudo) {
+ QStringList sudoPrograms;
+ sudoPrograms << "gksudo" << "kdesudo" << "sudo";
+ QStringList sudoParams;
+ sudoParams << filePath + " " + parameters.join(" ");
- qDebug() << "Starting process " << filePath << " args: " << parameters;
-
- if (!QProcess::startDetached(filePath, parameters)) {
+ foreach (const QString &sProg, sudoPrograms) {
+ qDebug() << "Starting process " << sProg <<" params: " << sudoParams;
+ if (!QProcess::startDetached(sProg, sudoParams)) {
+ continue;
+ } else {
+ sudo_started = true;
+ break;
+ }
+ }
+ }
+ if (!sudo_started && !QProcess::startDetached(filePath, parameters)) {
qDebug() << "Failed to start process.";
return;
}
+
#endif
/* Installer process should now be running. We exit */
More information about the Trustbridge-commits
mailing list