diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2013-09-28 05:03:05 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2015-12-23 02:22:31 +0100 |
commit | 22290fd99276cfad8db612764a00648a63eeb0a6 (patch) | |
tree | 83b9470defc1a06ad637613ac3f502e2ea0f4c0a | |
parent | 37c097719c0be5cfa238daf71e13288f2b510d73 (diff) | |
download | tdelibs-22290fd99276cfad8db612764a00648a63eeb0a6.tar.gz tdelibs-22290fd99276cfad8db612764a00648a63eeb0a6.zip |
Add sbin into the paths for search binary during substitute uid
This resolves Bug 1494
(cherry picked from commit bb36045b59e18db88a2a40f9346775193c9ede6b)
-rw-r--r-- | kio/kio/kservice.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/kio/kio/kservice.cpp b/kio/kio/kservice.cpp index bad9d7d35..76b91aec6 100644 --- a/kio/kio/kservice.cpp +++ b/kio/kio/kservice.cpp @@ -31,6 +31,7 @@ #include <unistd.h> #include <stdlib.h> +#include <tqregexp.h> #include <tqstring.h> #include <tqfile.h> #include <tqdir.h> @@ -206,13 +207,24 @@ KService::init( KDesktopFile *config ) m_strExec = config->readPathEntry( "Exec" ); if (kde4application && !m_strExec.startsWith("/")) { m_strExec = "KDEHOME=$HOME/" KDE4_DEFAULT_HOME " KDEDIRS=" + kde4applicationprefix + "/ XDG_DATA_DIRS=" + kde4applicationprefix + "/share XDG_CONFIG_DIRS=/etc/xdg/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$PATH "+m_strExec; - } else if (config->readBoolEntry("X-KDE-SubstituteUID")) { + } + else if (config->readBoolEntry("X-KDE-SubstituteUID")) { + TQString path = TQString::fromLocal8Bit(getenv("PATH")); + TQString command; + TQString params; int space = m_strExec.find(" "); - if (space==-1) - m_strExec = KStandardDirs::findExe(m_strExec); + if (space==-1) { + command = m_strExec; + } else { - const TQString command = m_strExec.left(space); - m_strExec.replace(command,KStandardDirs::findExe(command)); + command = m_strExec.left(space); + params = m_strExec.mid(space); + } + path.replace(TQRegExp("(^|:)(/usr/local|/usr)/bin($|:)"), "\\1\\2/sbin:\\2/bin\\3"); + path.replace(TQRegExp("(^|:)/bin($|:)"), "\\1/sbin:/bin\\2"); + m_strExec = KStandardDirs::findExe(command, path); + if (!m_strExec.isEmpty() && !params.isEmpty()) { + m_strExec += params; } } |