From b8623dbe471703ea2f5fcfa9fce258c1e183f61e Mon Sep 17 00:00:00 2001 From: olf Date: Thu, 11 Apr 2024 21:07:40 +0200 Subject: [PATCH] Implement proper sandboxing (SailJail) configuration (#77) * [flowplayer.desktop] Implement a proper SailJail configuration Originally developed by @poetaster and reviewed by @dcaliste in PR #75, see commits 68dc7f1 and fce86cd. * [FlowPlayer.cpp] Eliminate migration functions due to conflict with sandboxing --- flowplayer.desktop | 6 ++++- src/FlowPlayer.cpp | 59 ---------------------------------------------- 2 files changed, 5 insertions(+), 60 deletions(-) diff --git a/flowplayer.desktop b/flowplayer.desktop index f87a750..25e8bb3 100644 --- a/flowplayer.desktop +++ b/flowplayer.desktop @@ -6,4 +6,8 @@ Exec=flowplayer Name=FlowPlayer [X-Sailjail] -Sandboxing=Disabled +OrganizationName=sailfishos-applications +# ApplicationName does not have to be identical to Name +ApplicationName=flowplayer +# Add the required permissions here +Permissions=UserDirs;Audio;Bluetooth;Internet;RemovableMedia diff --git a/src/FlowPlayer.cpp b/src/FlowPlayer.cpp index dfb80e5..a862eff 100644 --- a/src/FlowPlayer.cpp +++ b/src/FlowPlayer.cpp @@ -22,61 +22,6 @@ bool isDBOpened; bool databaseWorking; -static void migrateSettings() -{ - const QString oldSettings = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/cepiperez/flowplayer.conf"; - const QString newSettings = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + ".conf"; - if (QFile::exists(oldSettings)) { - if (QDir().mkpath(QFileInfo(newSettings).path()) - && !QFile::rename(oldSettings, newSettings)) { - qWarning() << "unable to move old configuration from" << oldSettings << "to" << newSettings; - } - QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).rmdir("cepiperez"); - } -} - -static void migrateDatabase() -{ - const QString olderDb = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/cepiperez/flowplayer.db"; - const QString oldDb = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/flowplayer/flowplayer/flowplayer.db"; - const QString newDb = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.db"; - if (QFile::exists(oldDb)) { - if (QDir().mkpath(QFileInfo(newDb).path()) - && !QFile::rename(oldDb, newDb)) { - qWarning() << "unable to move old database from" << oldDb << "to" << newDb; - } - QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/flowplayer").rmdir("flowplayer"); - QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).rmdir("flowplayer"); - } else if (QFile::exists(olderDb)) { - if (QDir().mkpath(QFileInfo(newDb).path()) - && !QFile::rename(olderDb, newDb)) { - qWarning() << "unable to move old database from" << olderDb << "to" << newDb; - } - QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).rmdir("cepiperez"); - } -} - -static void migrateCache() -{ - const QString olderCache = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/flowplayer"; - const QString oldCache = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/flowplayer/flowplayer"; - const QString newCache = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); - if (QFileInfo(oldCache).isDir()) { - if (QDir().mkpath(QFileInfo(newCache).path()) - && !QDir().rename(oldCache, newCache)) { - qWarning() << "unable to move old cache from" << oldCache << "to" << newCache; - } - QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/flowplayer").rmdir("flowplayer"); - QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).rmdir("flowplayer"); - } else if (QFileInfo(olderCache).isDir()) { - if (QDir().mkpath(QFileInfo(newCache).path()) - && !QDir().rename(olderCache, newCache)) { - qWarning() << "unable to move old cache from" << olderCache << "to" << newCache; - } - QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).rmdir("flowplayer"); - } -} - int main(int argc, char *argv[]) { QTextCodec *linuxCodec = QTextCodec::codecForName("UTF-8"); @@ -86,10 +31,6 @@ int main(int argc, char *argv[]) app->setOrganizationName("sailfishos-applications"); app->setApplicationName("flowplayer"); - migrateSettings(); - migrateDatabase(); - migrateCache(); - QString lang; QTranslator translator;