Skip to content

Commit

Permalink
Implement proper sandboxing (SailJail) configuration (#77)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
Olf0 authored Apr 11, 2024
1 parent dee0d51 commit b8623db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 60 deletions.
6 changes: 5 additions & 1 deletion flowplayer.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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
59 changes: 0 additions & 59 deletions src/FlowPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -86,10 +31,6 @@ int main(int argc, char *argv[])
app->setOrganizationName("sailfishos-applications");
app->setApplicationName("flowplayer");

migrateSettings();
migrateDatabase();
migrateCache();

QString lang;
QTranslator translator;

Expand Down

0 comments on commit b8623db

Please sign in to comment.