From 2605e75757933b695294976b5ec227f4e5da20c6 Mon Sep 17 00:00:00 2001 From: Volker Lanz Date: Fri, 21 May 2010 17:12:44 +0000 Subject: [PATCH] properly handle cmd line args when invoking ourselves with root helper svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1129224 --- src/util/helpers.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/util/helpers.cpp b/src/util/helpers.cpp index df757e1..656c6a3 100644 --- a/src/util/helpers.cpp +++ b/src/util/helpers.cpp @@ -83,19 +83,17 @@ bool checkPermissions() { if (geteuid() != 0) { + KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); // only try to gain root privileges if we have a valid (kde|gk)su(do) command and // we did not try so before: the dontsu-option is there to make sure there are no // endless loops of calling the same non-working (kde|gk)su(do) binary again and again. - if (!suCommand().isEmpty() && !KCmdLineArgs::parsedArgs()->isSet("dontsu")) + if (!suCommand().isEmpty() && !args->isSet("dontsu")) { - QStringList args = qApp->arguments(); - - // first argument is our own command again (i.e., argv[0]) - if (!args.isEmpty()) - args.removeFirst(); - // arguments to partition manager must be _one_ argument to (kde|gk)su(do) - const QString suArgs = qApp->applicationFilePath() + args.join(" ") + " --dontsu"; + QString suArgs = qApp->applicationFilePath() + " --dontsu"; + for (qint32 i = 0; i < args->count(); i++) + suArgs += QString(" %1").arg(args->arg(i)); + if (QProcess::execute(suCommand(), QStringList() << suArgs) == 0) return false; }