kio: look through entire PATH for samba

This commit is contained in:
Peter Hoeg 2020-06-26 16:28:19 +08:00
parent b9928cbd0d
commit fdbf2e5527

View File

@ -1,28 +1,14 @@
Index: kio-5.17.0/src/core/ksambashare.cpp
===================================================================
--- kio-5.17.0.orig/src/core/ksambashare.cpp
+++ kio-5.17.0/src/core/ksambashare.cpp
@@ -67,13 +67,18 @@ KSambaSharePrivate::~KSambaSharePrivate(
diff --git a/src/core/ksambashare.cpp b/src/core/ksambashare.cpp
index 1895783..9fe7286 100644
--- a/src/core/ksambashare.cpp
+++ b/src/core/ksambashare.cpp
@@ -73,8 +73,7 @@ KSambaSharePrivate::~KSambaSharePrivate()
bool KSambaSharePrivate::isSambaInstalled()
{
- if (QFile::exists(QStringLiteral("/usr/sbin/smbd"))
- || QFile::exists(QStringLiteral("/usr/local/sbin/smbd"))) {
- return true;
+ const QByteArray pathEnv = qgetenv("PATH");
+ if (!pathEnv.isEmpty()) {
+ QLatin1Char pathSep(':');
+ QStringList paths = QFile::decodeName(pathEnv).split(pathSep, QString::SkipEmptyParts);
+ for (QStringList::iterator it = paths.begin(); it != paths.end(); ++it) {
+ it->append(QStringLiteral("/smbd"));
+ if (QFile::exists(*it)) {
+ return true;
+ }
+ }
const bool daemonExists =
- !QStandardPaths::findExecutable(QStringLiteral("smbd"),
- {QStringLiteral("/usr/sbin/"), QStringLiteral("/usr/local/sbin/")}).isEmpty();
+ !QStandardPaths::findExecutable(QStringLiteral("smbd")).isEmpty();
if (!daemonExists) {
qCDebug(KIO_CORE_SAMBASHARE) << "KSambaShare: Could not find smbd";
}
- //qDebug() << "Samba is not installed!";
-
return false;
}