diff --git a/src/Navaids/NavDataCache.cxx b/src/Navaids/NavDataCache.cxx index 4c919bc95..efe600e76 100644 --- a/src/Navaids/NavDataCache.cxx +++ b/src/Navaids/NavDataCache.cxx @@ -261,6 +261,9 @@ public: SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache at:" << path); readOnly = fgGetBool("/sim/fghome-readonly", false); + if (!readOnly && !path.canWrite()) { + throw sg_exception("Nav-cache file is not writeable"); + } int openFlags = readOnly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; @@ -276,6 +279,10 @@ public: throw sg_exception("Navcache failed to open:" + errMsg); } + if (!readOnly && (sqlite3_db_readonly(db, nullptr) != 0)) { + throw sg_exception("Nav-cache file opened but is not writeable"); + } + sqlite3_stmt_ptr checkTables = prepare("SELECT count(*) FROM sqlite_master WHERE name='properties'");