summaryrefslogtreecommitdiff
path: root/src/verify.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-31 16:08:09 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-31 16:08:09 +0300
commitea901526648c43ef8e961b3d7e051b9ca14b65ca (patch)
treecea5a96dc83518a94f79dddd645f3e4404179530 /src/verify.c
parent67108bf07a67811ea91fc965f3f1592a4a70044e (diff)
downloadapk-tools-ea901526648c43ef8e961b3d7e051b9ca14b65ca.tar.gz
apk-tools-ea901526648c43ef8e961b3d7e051b9ca14b65ca.tar.bz2
apk-tools-ea901526648c43ef8e961b3d7e051b9ca14b65ca.tar.xz
apk-tools-ea901526648c43ef8e961b3d7e051b9ca14b65ca.zip
apk: use *at instead of chdir+normal file syscall
this way we never change cwd, and relative filenames are always parsed consistently. this also helps filename construction in many places. this patch also changes '--root' to override location of all configuration to be in the new root. previously it depended on the file which one was used.
Diffstat (limited to 'src/verify.c')
-rw-r--r--src/verify.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/verify.c b/src/verify.c
index 82e9b2d..dc9ddb6 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -10,6 +10,7 @@
#include <errno.h>
#include <stdio.h>
+#include <fcntl.h>
#include <unistd.h>
#include "apk_applet.h"
@@ -19,12 +20,17 @@ static int verify_main(void *ctx, int argc, char **argv)
{
struct apk_sign_ctx sctx;
struct apk_istream *is;
+ struct apk_database db;
int i, r, ok, rc = 0;
apk_flags |= APK_ALLOW_UNTRUSTED;
+ r = apk_db_open(&db, apk_root, APK_OPENF_READ | APK_OPENF_NO_STATE);
+ if (r != 0)
+ return r;
+
for (i = 0; i < argc; i++) {
- apk_sign_ctx_init(&sctx, APK_SIGN_VERIFY, NULL);
- is = apk_bstream_gunzip_mpart(apk_bstream_from_file(argv[i]),
+ apk_sign_ctx_init(&sctx, APK_SIGN_VERIFY, NULL, db.keys_fd);
+ is = apk_bstream_gunzip_mpart(apk_bstream_from_file(AT_FDCWD, argv[i]),
apk_sign_ctx_mpart_cb, &sctx);
if (is == NULL) {
apk_error("%s: %s", strerror(errno), argv[i]);
@@ -43,6 +49,7 @@ static int verify_main(void *ctx, int argc, char **argv)
rc++;
apk_sign_ctx_free(&sctx);
}
+ apk_db_close(&db);
return rc;
}