Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 554af229 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

DB & MODULE: Check for obfuscation mode.

The obfuscation download mode can't change for the moment. It would
require to 'translate' filepaths, or be able to deal with non uniform
databases, don't do that for the moment.

Also update the changelog.
parent 5ab59ba3
Branches
Étiquettes
1 requête de fusion!119Download obfuscation
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
- Download the bakabase with obfuscation or not - Download the bakabase with obfuscation or not
- Add json-c to the download dependency script (add cmake as a requirement for that) - Add json-c to the download dependency script (add cmake as a requirement for that)
- Choose between static or shared library for liblektor
- Download the bakabase with obfuscation or not
# v2.1 (df74b85f) # v2.1 (df74b85f)
......
...@@ -158,6 +158,11 @@ bool database_config_queue_default(volatile sqlite3 *db); ...@@ -158,6 +158,11 @@ bool database_config_queue_default(volatile sqlite3 *db);
* for debug purpose. */ * for debug purpose. */
bool database_config_dump(volatile sqlite3 *db, FILE *f); bool database_config_dump(volatile sqlite3 *db, FILE *f);
/* Check obfuscation status. If no one is set, set it and return `true`. If
* there was already an obfuscation status, return `true` if the two are the
* same, `false` otherwise. */
bool database_config_obfuscation_check(volatile sqlite3 *db, int obfuscation);
/* Playlists */ /* Playlists */
struct lkt_playlist_metadata { struct lkt_playlist_metadata {
const char *name; const char *name;
......
...@@ -216,3 +216,33 @@ error: ...@@ -216,3 +216,33 @@ error:
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
return false; return false;
} }
bool
database_config_obfuscation_check(volatile sqlite3 *db, int obfuscation)
{
static const char *GET_SQL = "SELECT obfuscation FROM misc WHERE id = 42;";
static const char *SET_SQL = "UPDATE misc SET obfuscation = ? WHERE id = 42;";
sqlite3_stmt *stmt = 0;
SQLITE_PREPARE(db, stmt, GET_SQL, error);
if (SQLITE_ROW == sqlite3_step(stmt)) {
/* Obfuscation mode set */
sqlite3_finalize(stmt);
return obfuscation == sqlite3_column_int(stmt, 0);
}
else {
/* No obfuscation mode set */
sqlite3_finalize(stmt);
SQLITE_PREPARE(db, stmt, SET_SQL, error);
SQLITE_BIND_INT(db, stmt, 1, obfuscation, error);
SQLITE_STEP_DONE(db, stmt, error);
sqlite3_finalize(stmt);
return true;
}
error:
sqlite3_finalize(stmt);
return false;
}
...@@ -144,6 +144,7 @@ CREATE TABLE IF NOT EXISTS misc ...@@ -144,6 +144,7 @@ CREATE TABLE IF NOT EXISTS misc
, last_end_update INTEGER , last_end_update INTEGER
, update_job INTEGER NOT NULL CHECK(update_job >= 0) , update_job INTEGER NOT NULL CHECK(update_job >= 0)
, opened INTEGER NOT NULL CHECK(opened = 0 OR opened = 1) , opened INTEGER NOT NULL CHECK(opened = 0 OR opened = 1)
, obfuscation INTEGER CHECK(obfuscation = 0 OR obfuscation = 1)
); );
INSERT OR REPLACE INTO misc (id, update_job, opened) VALUES (42, 0, 0); INSERT OR REPLACE INTO misc (id, update_job, opened) VALUES (42, 0, 0);
...@@ -489,7 +489,13 @@ module_repo_new(struct module_repo_internal *repo_, struct queue *queue, volatil ...@@ -489,7 +489,13 @@ module_repo_new(struct module_repo_internal *repo_, struct queue *queue, volatil
} }
obfuscate = obfuscate ? 1 : 0; /* Safe values */ obfuscate = obfuscate ? 1 : 0; /* Safe values */
LOG_WARN("REPO", "Downloading base in %s mode, mode is number: %d", obfuscate ? "obfuscation" : "clear", obfuscate); LOG_WARN("REPO", "Downloading base in %s mode, mode is number: %d",
obfuscate ? "obfuscation" : "clear", obfuscate);
if (!database_config_obfuscation_check(db, obfuscate)) {
LOG_ERROR("REPO", "Database obfuscation mismatch. Because I'm a coward I will exit");
exit(EXIT_FAILURE);
}
struct module_repo_internal repo = { struct module_repo_internal repo = {
.version = 1, .version = 1,
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter