diff options
author | Timo Teräs <timo.teras@iki.fi> | 2022-03-06 16:07:42 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2022-03-06 16:07:42 +0200 |
commit | 00e397d5646df33e2823d73e2388013d461ed5e9 (patch) | |
tree | 817477b24169899b41dad2b3bad5b60919841082 /src | |
parent | 62bc43d2a4d60de3ace3f385625ea8dc0ba957f3 (diff) | |
download | apk-tools-00e397d5646df33e2823d73e2388013d461ed5e9.tar.gz apk-tools-00e397d5646df33e2823d73e2388013d461ed5e9.tar.bz2 apk-tools-00e397d5646df33e2823d73e2388013d461ed5e9.tar.xz apk-tools-00e397d5646df33e2823d73e2388013d461ed5e9.zip |
db: honor APK_OPENF_NO_STATE again
Do not call apk_db_read_layer() or try to process the layer
if APK_OPENF_NO_STATE is specified. It might fail because of
non-existing database directory. Based on patch by Daniel.
fixes commit 9e4dd29f "db: prepare database reading for layers"
Fixes #10821
Reported-and-analyzed-by: Daniel Kolesa <daniel@octaforge.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/database.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/database.c b/src/database.c index bf970b1..28f3cba 100644 --- a/src/database.c +++ b/src/database.c @@ -1730,16 +1730,18 @@ int apk_db_open(struct apk_database *db, struct apk_ctx *ac) apk_db_read_overlay(db, apk_istream_from_fd(STDIN_FILENO)); } - for (i = 0; i < APK_DB_LAYER_NUM; i++) { - r = apk_db_read_layer(db, i); - if (r) { - if (i != APK_DB_LAYER_ROOT) continue; - if (!(r == -ENOENT && (ac->open_flags & APK_OPENF_CREATE))) { - msg = "Unable to read database"; - goto ret_r; + if ((db->ctx->flags & APK_OPENF_NO_STATE) != APK_OPENF_NO_STATE) { + for (i = 0; i < APK_DB_LAYER_NUM; i++) { + r = apk_db_read_layer(db, i); + if (r) { + if (i != APK_DB_LAYER_ROOT) continue; + if (!(r == -ENOENT && (ac->open_flags & APK_OPENF_CREATE))) { + msg = "Unable to read database"; + goto ret_r; + } } + db->active_layers |= BIT(i); } - db->active_layers |= BIT(i); } if (!(ac->open_flags & APK_OPENF_NO_INSTALLED_REPO)) { |