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>
cute-signatures
parent
62bc43d2a4
commit
00e397d564
|
@ -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));
|
apk_db_read_overlay(db, apk_istream_from_fd(STDIN_FILENO));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < APK_DB_LAYER_NUM; i++) {
|
if ((db->ctx->flags & APK_OPENF_NO_STATE) != APK_OPENF_NO_STATE) {
|
||||||
r = apk_db_read_layer(db, i);
|
for (i = 0; i < APK_DB_LAYER_NUM; i++) {
|
||||||
if (r) {
|
r = apk_db_read_layer(db, i);
|
||||||
if (i != APK_DB_LAYER_ROOT) continue;
|
if (r) {
|
||||||
if (!(r == -ENOENT && (ac->open_flags & APK_OPENF_CREATE))) {
|
if (i != APK_DB_LAYER_ROOT) continue;
|
||||||
msg = "Unable to read database";
|
if (!(r == -ENOENT && (ac->open_flags & APK_OPENF_CREATE))) {
|
||||||
goto ret_r;
|
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)) {
|
if (!(ac->open_flags & APK_OPENF_NO_INSTALLED_REPO)) {
|
||||||
|
|
Loading…
Reference in New Issue