Only fallback to MDB_RDONLY if readonly database is requested

Somewhat similarly to commit 70a1efa52b,
only allow read-only environment if read-only is requested, writers
are better off failing early.
This commit is contained in:
Panu Matilainen 2017-08-28 19:33:40 +03:00
parent 2822ccbcdf
commit b052d69474
1 changed files with 1 additions and 1 deletions

View File

@ -171,7 +171,7 @@ static int db_init(rpmdb rdb, const char * dbhome)
eflags |= MDB_MAPASYNC;
eflags |= MDB_NOTLS;
if (access(dbhome, W_OK))
if (access(dbhome, W_OK) && (rdb->db_mode & O_ACCMODE) == O_RDONLY)
eflags |= MDB_RDONLY;
rc = mdb_env_open(env, dbhome, eflags, rdb->db_perms);