Sophie

Sophie

distrib > Fedora > 16 > x86_64 > media > updates-src > by-pkgid > 5239fc3d3d09bf34966da2e433c7fde3 > files > 1

kde-workspace-4.8.5-3.fc16.src.rpm

From 70505b9c7871b174e6f5bf1fb3d17b4e5fab14af Mon Sep 17 00:00:00 2001
Message-Id: <70505b9c7871b174e6f5bf1fb3d17b4e5fab14af.1359767724.git.kevin.kofler@chello.at>
From: Kevin Kofler <kevin.kofler@chello.at>
Date: Sat, 2 Feb 2013 01:59:45 +0100
Subject: [PATCH] kcmdatetimehelper: Hardcode PATH because $PATH is empty
 here.

Unfortunately, we cannot rely on the $PATH environment variable in KAuth
helpers, because D-Bus activation clears it. So we have to use a
reasonable default for the KStandardDirs::findExe search path, and
actually use the return value of KStandardDirs::findExe in the calls to
KProcess::execute.
---
 kcontrol/dateandtime/helper.cpp |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/kcontrol/dateandtime/helper.cpp b/kcontrol/dateandtime/helper.cpp
index 5a946d8..9168db3 100644
--- a/kcontrol/dateandtime/helper.cpp
+++ b/kcontrol/dateandtime/helper.cpp
@@ -48,6 +48,10 @@
 #include <sys/stat.h>
 #endif
 
+// We cannot rely on the $PATH environment variable, because D-Bus activation
+// clears it. So we have to use a reasonable default.
+static const QString exePath = QLatin1String("/usr/sbin:/usr/bin:/sbin:/bin");
+
 int ClockHelper::ntp( const QStringList& ntpServers, bool ntpEnabled,
                       const QString& ntpUtility )
 {
@@ -96,8 +100,9 @@ int ClockHelper::date( const QString& newdate, const QString& olddate )
         return DateError;
     }
 
-    if (!KStandardDirs::findExe("hwclock").isEmpty()) {
-        KProcess::execute("hwclock", QStringList() << "--systohc");
+    QString hwclock = KStandardDirs::findExe("hwclock", exePath);
+    if (!hwclock.isEmpty()) {
+        KProcess::execute(hwclock, QStringList() << "--systohc");
     }
     return 0;
 }
@@ -172,8 +177,9 @@ int ClockHelper::tz( const QString& selectedzone )
 #else
         QString tz = "/usr/share/zoneinfo/" + selectedzone;
 
-        if( !KStandardDirs::findExe( "zic" ).isEmpty()) {
-            KProcess::execute("zic", QStringList() << "-l" << selectedzone);
+        QString zic = KStandardDirs::findExe("zic", exePath);
+        if (!zic.isEmpty()) {
+            KProcess::execute(zic, QStringList() << "-l" << selectedzone);
         } else if (!QFile::remove("/etc/localtime")) {
           ret |= TimezoneError;
         } else if (!QFile::copy(tz, "/etc/localtime")) {
-- 
1.7.7.6