summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-06-12 13:48:42 +0300
committerTimo Teräs <timo.teras@iki.fi>2010-06-12 13:48:42 +0300
commit8b317678e3a440ccbb3534cc531ccc788d0aa490 (patch)
treec69e041001b018a6b1713d27e07a85aea23cb93f
parent3062d681f9052aabd4e02884e67a0fa1cf413f8b (diff)
downloadapk-tools-8b317678e3a440ccbb3534cc531ccc788d0aa490.tar.gz
apk-tools-8b317678e3a440ccbb3534cc531ccc788d0aa490.tar.bz2
apk-tools-8b317678e3a440ccbb3534cc531ccc788d0aa490.tar.xz
apk-tools-8b317678e3a440ccbb3534cc531ccc788d0aa490.zip
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.
-rw-r--r--src/database.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/database.c b/src/database.c
index ca90199..a5113cd 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1037,6 +1037,10 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
int r, rr = 0;
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) {
msg = "Invalid open flags (internal error)";
r = -1;