db: return hard error if repository opening fails
otherwise we can accept unsigned repositories, and install bad packages.cute-signatures
parent
6f8526da3e
commit
8c19869c29
|
@ -883,7 +883,7 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
|
||||||
struct apk_repository_url *repo = NULL;
|
struct apk_repository_url *repo = NULL;
|
||||||
struct stat64 st;
|
struct stat64 st;
|
||||||
apk_blob_t blob;
|
apk_blob_t blob;
|
||||||
int r;
|
int r, rr = 0;
|
||||||
|
|
||||||
memset(db, 0, sizeof(*db));
|
memset(db, 0, sizeof(*db));
|
||||||
apk_hash_init(&db->available.names, &pkg_name_hash_ops, 1000);
|
apk_hash_init(&db->available.names, &pkg_name_hash_ops, 1000);
|
||||||
|
@ -978,22 +978,26 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
|
||||||
apk_repos = "etc/apk/repositories";
|
apk_repos = "etc/apk/repositories";
|
||||||
blob = apk_blob_from_file(db->root_fd, apk_repos);
|
blob = apk_blob_from_file(db->root_fd, apk_repos);
|
||||||
if (!APK_BLOB_IS_NULL(blob)) {
|
if (!APK_BLOB_IS_NULL(blob)) {
|
||||||
apk_blob_for_each_segment(blob, "\n",
|
r = apk_blob_for_each_segment(
|
||||||
apk_db_add_repository, db);
|
blob, "\n",
|
||||||
|
apk_db_add_repository, db);
|
||||||
|
rr = r ?: rr;
|
||||||
free(blob.ptr);
|
free(blob.ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & APK_OPENF_NO_REPOS)) {
|
if (!(flags & APK_OPENF_NO_REPOS)) {
|
||||||
list_for_each_entry(repo, &apk_repository_list.list, list)
|
list_for_each_entry(repo, &apk_repository_list.list, list) {
|
||||||
apk_db_add_repository(db, APK_BLOB_STR(repo->url));
|
r = apk_db_add_repository(db, APK_BLOB_STR(repo->url));
|
||||||
|
rr = r ?: rr;
|
||||||
|
}
|
||||||
|
|
||||||
if (apk_flags & APK_UPDATE_CACHE)
|
if (apk_flags & APK_UPDATE_CACHE)
|
||||||
apk_db_index_write_nr_cache(db);
|
apk_db_index_write_nr_cache(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return rr;
|
||||||
|
|
||||||
ret_errno:
|
ret_errno:
|
||||||
r = -errno;
|
r = -errno;
|
||||||
|
|
Loading…
Reference in New Issue