From 6694516890d12e11b89f76a480032cc60c1ab4e2 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sat, 30 Aug 2025 22:41:00 -0300 Subject: 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 --- src/database.cc | 8 ++++++++ 1 file changed, 8 insertions(+) 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; -- cgit v1.2.3