Commit 7b411190 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Check executables exist in PATH before passing them to QProcess

parent 563b110d
Pipeline #132234 passed with stage
in 5 minutes and 7 seconds
......@@ -15,6 +15,7 @@
#include <QCoreApplication>
#include <QDBusConnection>
#include <QProcess>
#include <QStandardPaths>
#include <QTimer>
#include <iostream>
......@@ -41,8 +42,8 @@ bool AkonadiStarter::start(bool verbose)
serverArgs << QStringLiteral("--verbose");
}
const bool ok = QProcess::startDetached(QStringLiteral("akonadi_control"), serverArgs);
if (!ok) {
const QString exec = QStandardPaths::findExecutable(QStringLiteral("akonadi_control"));
if (exec.isEmpty() || !QProcess::startDetached(QStringLiteral("akonadi_control"), serverArgs)) {
std::cerr << "Error: unable to execute binary akonadi_control" << std::endl;
return false;
}
......
......@@ -31,6 +31,7 @@
#include <QDBusServiceWatcher>
#include <QProcess>
#include <QScopedPointer>
#include <QStandardPaths>
#include <QTimer>
#include <qnamespace.h>
......@@ -207,8 +208,8 @@ bool ServerManager::start()
if (hasInstanceIdentifier()) {
args << QStringLiteral("--instance") << instanceIdentifier();
}
const bool ok = QProcess::startDetached(QStringLiteral("akonadi_control"), args);
if (!ok) {
const QString exec = QStandardPaths::findExecutable(QStringLiteral("akonadi_control"));
if (exec.isEmpty() || !QProcess::startDetached(QStringLiteral("akonadi_control"), args)) {
qCWarning(AKONADICORE_LOG) << "Unable to execute akonadi_control, falling back to D-Bus auto-launch";
QDBusReply<void> reply = QDBusConnection::sessionBus().interface()->startService(ServerManager::serviceName(ServerManager::Control));
if (!reply.isValid()) {
......@@ -236,7 +237,10 @@ bool ServerManager::stop()
void ServerManager::showSelfTestDialog(QWidget *parent)
{
Q_UNUSED(parent)
QProcess::startDetached(QStringLiteral("akonadiselftest"), QStringList());
const QString exec = QStandardPaths::findExecutable(QStringLiteral("akonadiselftest"));
if (exec.isEmpty() || !QProcess::startDetached(QStringLiteral("akonadiselftest"), QStringList())) {
qCWarning(AKONADICORE_LOG) << "Could not find akonadiselftest in PATH.";
}
}
bool ServerManager::isRunning()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment