summaryrefslogtreecommitdiff
path: root/src/context.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-10-09 13:40:14 +0300
committerTimo Teräs <timo.teras@iki.fi>2020-10-09 16:09:19 +0300
commit705e002bb0ab1a317df73e4efac08ebd25dd4d8c (patch)
tree37b262e1627188df64ea69e74b44df203b85b786 /src/context.c
parenta627ab8eb8387ebf5735cf525ae72bfa159aa39a (diff)
downloadapk-tools-705e002bb0ab1a317df73e4efac08ebd25dd4d8c.tar.gz
apk-tools-705e002bb0ab1a317df73e4efac08ebd25dd4d8c.tar.bz2
apk-tools-705e002bb0ab1a317df73e4efac08ebd25dd4d8c.tar.xz
apk-tools-705e002bb0ab1a317df73e4efac08ebd25dd4d8c.zip
rename adb_trust to apk_trust, and use it as package signature keystore too
Diffstat (limited to 'src/context.c')
-rw-r--r--src/context.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/context.c b/src/context.c
index 6f953b0..784f082 100644
--- a/src/context.c
+++ b/src/context.c
@@ -26,7 +26,7 @@ void apk_ctx_init(struct apk_ctx *ac)
void apk_ctx_free(struct apk_ctx *ac)
{
apk_id_cache_free(&ac->id_cache);
- adb_trust_free(&ac->trust);
+ apk_trust_free(&ac->trust);
apk_string_array_free(&ac->repository_list);
apk_string_array_free(&ac->private_keys);
}
@@ -55,17 +55,14 @@ int apk_ctx_prepare(struct apk_ctx *ac)
return 0;
}
-int apk_ctx_fd_keys(struct apk_ctx *ac)
-{
- if (ac->keys_fd <= 0) ac->keys_fd = openat(ac->root_fd, ac->keys_dir, O_RDONLY | O_CLOEXEC);
- return ac->keys_fd;
-}
-
-struct adb_trust *apk_ctx_get_trust(struct apk_ctx *ac)
+struct apk_trust *apk_ctx_get_trust(struct apk_ctx *ac)
{
if (!ac->trust.mdctx) {
- int r = adb_trust_init(&ac->trust, dup(apk_ctx_fd_keys(ac)), ac->private_keys);
+ int r = apk_trust_init(&ac->trust,
+ openat(ac->root_fd, ac->keys_dir, O_RDONLY | O_CLOEXEC),
+ ac->private_keys);
if (r) return ERR_PTR(r);
+ ac->trust.allow_untrusted = !!(ac->flags & APK_ALLOW_UNTRUSTED);
}
return &ac->trust;
}