diff options
author | Michael Schroeder <mls@suse.de> | 2013-11-18 11:31:05 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2013-11-18 11:31:05 +0100 |
commit | 6414f1c4a66a099e9868d24f2c8a52da845a29db (patch) | |
tree | 2c3858ead8f3d1b7c7cf76a94b66e92c5ad86306 | |
parent | 1aed650c8157abfd95c57646d8c8e4ffc488e084 (diff) | |
download | libsolv-6414f1c4a66a099e9868d24f2c8a52da845a29db.tar.gz libsolv-6414f1c4a66a099e9868d24f2c8a52da845a29db.tar.bz2 libsolv-6414f1c4a66a099e9868d24f2c8a52da845a29db.zip |
split repo_find_pubkeys from repo_verify_sigdata
-rw-r--r-- | bindings/solv.i | 13 | ||||
-rw-r--r-- | ext/libsolvext.ver | 1 | ||||
-rw-r--r-- | ext/repo_pubkey.c | 46 | ||||
-rw-r--r-- | ext/repo_pubkey.h | 1 |
4 files changed, 43 insertions, 18 deletions
diff --git a/bindings/solv.i b/bindings/solv.i index ef658f4..da032a9 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -1629,6 +1629,19 @@ rb_eval_string( return sel; } +#ifdef ENABLE_PUBKEY + %newobject find_pubkey; + XSolvable *find_pubkey(const char *keyid) { + Queue q; + Id p; + queue_init(&q); + repo_find_pubkeys($self, keyid, &q); + p = q.count ? q.elements[0] : 0; + queue_free(&q); + return new_XSolvable($self->pool, p); + } +#endif + bool __eq__(Repo *repo) { return $self == repo; } diff --git a/ext/libsolvext.ver b/ext/libsolvext.ver index 8b096b8..edede2a 100644 --- a/ext/libsolvext.ver +++ b/ext/libsolvext.ver @@ -37,6 +37,7 @@ SOLV_1.0 { repo_add_susetags; repo_add_updateinfoxml; repo_add_zyppdb_products; + repo_find_pubkeys; repo_verify_sigdata; rpm_byfp; rpm_byrpmdbid; diff --git a/ext/repo_pubkey.c b/ext/repo_pubkey.c index b1a9aa0..50066cc 100644 --- a/ext/repo_pubkey.c +++ b/ext/repo_pubkey.c @@ -1147,10 +1147,8 @@ solvsig_free(Solvsig *ss) solv_free(ss); } -#ifdef ENABLE_PGPVRFY - static int -repo_verify_sigdata_cmp(const void *va, const void *vb, void *dp) +repo_find_pubkeys_cmp(const void *va, const void *vb, void *dp) { Pool *pool = dp; Id a = *(Id *)va; @@ -1159,33 +1157,45 @@ repo_verify_sigdata_cmp(const void *va, const void *vb, void *dp) return strcmp(pool_id2str(pool, pool->solvables[b].evr), pool_id2str(pool, pool->solvables[a].evr)); } +void +repo_find_pubkeys(Repo *repo, const char *keyid, Queue *q) +{ + Id p; + Solvable *s; + + queue_empty(q); + if (!keyid) + return; + queue_init(q); + FOR_REPO_SOLVABLES(repo, p, s) + { + const char *kidstr, *evr = pool_id2str(s->repo->pool, s->evr); + + if (!evr || strncmp(evr, keyid + 8, 8) != 0) + continue; + kidstr = solvable_lookup_str(s, PUBKEY_KEYID); + if (kidstr && !strcmp(kidstr, keyid)) + queue_push(q, p); + } + if (q->count > 1) + solv_sort(q->elements, q->count, sizeof(Id), repo_find_pubkeys_cmp, repo->pool); +} + +#ifdef ENABLE_PGPVRFY + /* warning: does not check key expiry/revokation, like gpgv or rpm */ /* returns the Id of the pubkey that verified the signature */ Id repo_verify_sigdata(Repo *repo, unsigned char *sigdata, int sigdatal, const char *keyid) { Id p; - Solvable *s; Queue q; int i; if (!sigdata || !keyid) return 0; queue_init(&q); - FOR_REPO_SOLVABLES(repo, p, s) - { - const char *evr = pool_id2str(s->repo->pool, s->evr); - const char *kidstr; - - if (!evr || strncmp(evr, keyid + 8, 8) != 0) - continue; - kidstr = solvable_lookup_str(s, PUBKEY_KEYID); - if (!kidstr || strcmp(kidstr, keyid) != 0) - continue; - queue_push(&q, p); - } - if (q.count > 1) - solv_sort(q.elements, q.count, sizeof(Id), repo_verify_sigdata_cmp, repo->pool); + repo_find_pubkeys(repo, keyid, &q); for (i = 0; i < q.count; i++) { int pubdatal; diff --git a/ext/repo_pubkey.h b/ext/repo_pubkey.h index e3c8fb8..cfe9def 100644 --- a/ext/repo_pubkey.h +++ b/ext/repo_pubkey.h @@ -33,4 +33,5 @@ void solvsig_free(Solvsig *ss); Id solvsig_verify(Solvsig *ss, Repo *repo, Chksum *chk); Id repo_verify_sigdata(Repo *repo, unsigned char *sigdata, int sigdatal, const char *keyid); +void repo_find_pubkeys(Repo *repo, const char *keyid, Queue *q); |