Commit 8b317678 authored by Timo Teräs's avatar Timo Teräs

db: --simulate never needs write access to db

So open the db in read-only mode instead. This allows --simulate to
be run as non-root user.
parent 3062d681
...@@ -1037,6 +1037,10 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts) ...@@ -1037,6 +1037,10 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
int r, rr = 0; int r, rr = 0;
memset(db, 0, sizeof(*db)); memset(db, 0, sizeof(*db));
if (apk_flags & APK_SIMULATE) {
dbopts->open_flags &= ~(APK_OPENF_CREATE | APK_OPENF_WRITE);
dbopts->open_flags |= APK_OPENF_READ;
}
if (dbopts->open_flags == 0) { if (dbopts->open_flags == 0) {
msg = "Invalid open flags (internal error)"; msg = "Invalid open flags (internal error)";
r = -1; r = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment