summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2013-09-28 05:03:05 +0200
committerSlávek Banko <slavek.banko@axis.cz>2013-09-28 05:03:05 +0200
commitbb36045b59e18db88a2a40f9346775193c9ede6b (patch)
treebf2f1ba2bc1a2d7d76b7458aca54288095d79683
parent6e81fa9ce19536f7b5c7de37f710a416bb31eaf3 (diff)
downloadtdelibs-bb36045b59e18db88a2a40f9346775193c9ede6b.tar.gz
tdelibs-bb36045b59e18db88a2a40f9346775193c9ede6b.zip
Add sbin into the paths for search binary during substitute uid
This resolves Bug 1494
-rw-r--r--tdeio/tdeio/kservice.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/tdeio/tdeio/kservice.cpp b/tdeio/tdeio/kservice.cpp
index a4c67f335..8845e126e 100644
--- a/tdeio/tdeio/kservice.cpp
+++ b/tdeio/tdeio/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 = "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-TDE-SubstituteUID") || config->readBoolEntry("X-KDE-SubstituteUID")) {
+ }
+ else if (config->readBoolEntry("X-TDE-SubstituteUID") || 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 = TDEStandardDirs::findExe(m_strExec);
+ if (space==-1) {
+ command = m_strExec;
+ }
else {
- const TQString command = m_strExec.left(space);
- m_strExec.replace(command,TDEStandardDirs::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 = TDEStandardDirs::findExe(command, path);
+ if (!m_strExec.isEmpty() && !params.isEmpty()) {
+ m_strExec += params;
}
}