aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-08-30 22:41:00 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-08-30 22:41:00 -0300
commit6694516890d12e11b89f76a480032cc60c1ab4e2 (patch)
treeb452d1142cd8ef3797e400f7bdf1b78b070be6cc
parent9c29c27aa876a355b483cdd508e380905624bd27 (diff)
downloadquerymanager-6694516890d12e11b89f76a480032cc60c1ab4e2.tar.gz
querymanager-6694516890d12e11b89f76a480032cc60c1ab4e2.zip
add check to make sure the database is open with write permissions
Using `sqlite_open` with `SQLITE_OPEN_READWRITE` doesn't guarantee the database will be open with read-write permissions. - See: https://www.sqlite.org/c3ref/open.html
-rw-r--r--src/database.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/database.cc b/src/database.cc
index 104224d..4b06386 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -2410,6 +2410,14 @@ bool InitDatabase(void){
return false;
}
+ if(sqlite3_db_readonly(g_Database, NULL)){
+ LOG_ERR("Failed to open database file \"%s\" with WRITE PERMISSIONS."
+ " Make sure the file has the appropriate permissions and is"
+ " owned by the same user running the query manager.",
+ g_DatabaseFile);
+ return false;
+ }
+
if(!InitStatementCache()){
LOG_ERR("Failed to initialize statement cache");
return false;