From 88ee2383f7c30c2883dbb9b90fa1553e97e7658d Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 26 Dec 2021 18:21:48 +0100 Subject: [PATCH] Switch to exile.h --- .gitmodules | 6 +++--- cli/sandboxedprocessor.cpp | 12 ++++++------ gui/main.cpp | 18 ++++++++---------- shared/shared.pro | 2 +- submodules/exile.h | 1 + submodules/qssb.h | 1 - 6 files changed, 19 insertions(+), 21 deletions(-) create mode 160000 submodules/exile.h delete mode 160000 submodules/qssb.h diff --git a/.gitmodules b/.gitmodules index ba48fd5..3ed67ad 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "submodules/qssb.h"] - path = submodules/qssb.h - url = https://gitea.quitesimple.org/crtxcr/qssb.h +[submodule "submodules/exile.h"] + path = submodules/exile.h + url = https://gitea.quitesimple.org/crtxcr/exile.h diff --git a/cli/sandboxedprocessor.cpp b/cli/sandboxedprocessor.cpp index 3341c57..3f722d9 100644 --- a/cli/sandboxedprocessor.cpp +++ b/cli/sandboxedprocessor.cpp @@ -8,7 +8,7 @@ #include "nothingprocessor.h" #include "odtprocessor.h" #include "odsprocessor.h" -#include "../submodules/qssb.h/qssb.h" +#include "../submodules/exile.h/exile.h" #include "logger.h" static DefaultTextProcessor *defaultTextProcessor = new DefaultTextProcessor(); @@ -26,26 +26,26 @@ static QMap processors{ void SandboxedProcessor::enableSandbox(QString readablePath) { - struct qssb_policy *policy = qssb_init_policy(); + struct exile_policy *policy = exile_init_policy(); - policy->namespace_options = QSSB_UNSHARE_NETWORK | QSSB_UNSHARE_USER; + policy->namespace_options = EXILE_UNSHARE_NETWORK | EXILE_UNSHARE_USER; if(!readablePath.isEmpty()) { std::string readablePathLocation = readablePath.toStdString(); - qssb_append_path_policy(policy, QSSB_FS_ALLOW_READ, readablePathLocation.c_str()); + exile_append_path_policy(policy, EXILE_FS_ALLOW_ALL_READ, readablePathLocation.c_str()); } else { policy->no_fs = 1; } - int ret = qssb_enable_policy(policy); + int ret = exile_enable_policy(policy); if(ret != 0) { qDebug() << "Failed to establish sandbox: " << ret; exit(EXIT_FAILURE); } - qssb_free_policy(policy); + exile_free_policy(policy); } void SandboxedProcessor::printResults(const QVector &pageData) diff --git a/gui/main.cpp b/gui/main.cpp index 06dcfeb..02819c6 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -8,7 +8,7 @@ #include "searchresult.h" #include "pdfpreview.h" #include "../shared/common.h" -#include "../submodules/qssb.h/qssb.h" +#include "../submodules/exile.h/exile.h" #include "ipcserver.h" int main(int argc, char *argv[]) @@ -41,25 +41,23 @@ int main(int argc, char *argv[]) QMessageBox::critical(nullptr, "Error", errorMsg); } - struct qssb_policy *policy = qssb_init_policy(); + struct exile_policy *policy = exile_init_policy(); std::string appDataLocation = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation).toStdString(); std::string cacheDataLocation = QStandardPaths::writableLocation(QStandardPaths::CacheLocation).toStdString(); std::string sockPath = socketPath.toStdString(); - policy->namespace_options = QSSB_UNSHARE_NETWORK | QSSB_UNSHARE_USER; + policy->namespace_options = EXILE_UNSHARE_NETWORK | EXILE_UNSHARE_USER; - qssb_append_path_policy(policy, QSSB_FS_ALLOW_READ | QSSB_FS_ALLOW_REMOVE_FILE, "/"); - qssb_append_path_policy(policy, QSSB_FS_ALLOW_READ | QSSB_FS_ALLOW_REMOVE_FILE | QSSB_FS_ALLOW_WRITE, - appDataLocation.c_str()); - qssb_append_path_policy(policy, QSSB_FS_ALLOW_READ | QSSB_FS_ALLOW_REMOVE_FILE | QSSB_FS_ALLOW_WRITE, - cacheDataLocation.c_str()); + exile_append_path_policy(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_REMOVE_FILE, "/"); + exile_append_path_policy(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE, appDataLocation.c_str()); + exile_append_path_policy(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE, cacheDataLocation.c_str()); - int ret = qssb_enable_policy(policy); + int ret = exile_enable_policy(policy); if(ret != 0) { qDebug() << "Failed to establish sandbox"; return 1; } - qssb_free_policy(policy); + exile_free_policy(policy); Common::setupAppInfo(); QApplication a(argc, argv); diff --git a/shared/shared.pro b/shared/shared.pro index 1e943ee..fbbdd8b 100644 --- a/shared/shared.pro +++ b/shared/shared.pro @@ -13,7 +13,7 @@ TEMPLATE = lib CONFIG += staticlib CONFIG += c++17 -INCLUDEPATH += $$PWD/../sandbox/qssb.h/ +INCLUDEPATH += $$PWD/../sandbox/exile.h/ # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings diff --git a/submodules/exile.h b/submodules/exile.h new file mode 160000 index 0000000..d742397 --- /dev/null +++ b/submodules/exile.h @@ -0,0 +1 @@ +Subproject commit d742397b522eb91513bab54a3aa992dfb7121462 diff --git a/submodules/qssb.h b/submodules/qssb.h deleted file mode 160000 index 692c9b5..0000000 --- a/submodules/qssb.h +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 692c9b54b7b5fdca6a416d91d3f34d15af185c33