gui: main: Add --no-sandbox

This commit is contained in:
Albert S. 2022-01-04 23:44:37 +01:00
parent ea1d027621
commit 2e3b008207

View File

@ -4,6 +4,7 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QProcess> #include <QProcess>
#include <QDir> #include <QDir>
#include <QCommandLineParser>
#include "mainwindow.h" #include "mainwindow.h"
#include "searchresult.h" #include "searchresult.h"
@ -65,21 +66,22 @@ int main(int argc, char *argv[])
QString socketPath = "/tmp/looqs-spawner"; QString socketPath = "/tmp/looqs-spawner";
if(argc > 1) if(argc > 1)
{ {
Common::setupAppInfo();
QApplication a(argc, argv);
QString arg = argv[1]; QString arg = argv[1];
if(arg == "ipc") if(arg == "ipc")
{ {
Common::setupAppInfo();
QApplication a(argc, argv);
IpcServer *ipcserver = new IpcServer(); IpcServer *ipcserver = new IpcServer();
qDebug() << "Launching ipc"; qDebug() << "Launching IPC Server";
if(!ipcserver->startSpawner(socketPath)) if(!ipcserver->startSpawner(socketPath))
{ {
qCritical() << "Error failed to spawn"; qCritical() << "Error failed to spawn";
return 1; return 1;
} }
qDebug() << "Launched"; qDebug() << "Launched IPC Server";
return a.exec();
} }
return a.exec();
} }
QProcess process; QProcess process;
QStringList args; QStringList args;
@ -91,7 +93,25 @@ int main(int argc, char *argv[])
QMessageBox::critical(nullptr, "Error", errorMsg); QMessageBox::critical(nullptr, "Error", errorMsg);
} }
Common::setupAppInfo(); Common::setupAppInfo();
enableSandbox(socketPath); QCommandLineParser parser;
parser.addOption({{"s", "no-sandbox"}, "Disable sandboxing"});
QStringList appArgs;
for(int i = 0; i < argc; i++)
{
appArgs.append(argv[i]);
}
parser.parse(appArgs);
if(!parser.isSet("no-sandbox"))
{
enableSandbox(socketPath);
qInfo() << "Sandbox: on";
}
else
{
qInfo() << "Sandbox: off";
}
// Keep this post sandbox, afterwards does not work (suspect due to threads, but unconfirmed)
QApplication a(argc, argv); QApplication a(argc, argv);
try try
{ {