Check nav-cache write-ability explicitly.
Check the file permissions before opening using the new SGPath APIs, and validate the result using Sqlite APIs after opening.
This commit is contained in:
parent
45c6ec216f
commit
d343496084
1 changed files with 7 additions and 0 deletions
|
@ -261,6 +261,9 @@ public:
|
||||||
SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache at:" << path);
|
SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache at:" << path);
|
||||||
|
|
||||||
readOnly = fgGetBool("/sim/fghome-readonly", false);
|
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 :
|
int openFlags = readOnly ? SQLITE_OPEN_READONLY :
|
||||||
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
|
||||||
|
@ -276,6 +279,10 @@ public:
|
||||||
throw sg_exception("Navcache failed to open:" + errMsg);
|
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 =
|
sqlite3_stmt_ptr checkTables =
|
||||||
prepare("SELECT count(*) FROM sqlite_master WHERE name='properties'");
|
prepare("SELECT count(*) FROM sqlite_master WHERE name='properties'");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue