diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2014-09-30 21:00:03 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2014-10-01 01:12:54 +0200 |
commit | 7ee01c86669327b2af63c8ed9390bcbf071cdac5 (patch) | |
tree | 72f1a5f494025d24e231451913024ab7a999de30 /lib/libalpm | |
parent | aec4241af24a1c68dacadb31ae38f05bdccfe799 (diff) | |
download | pacman-7ee01c86669327b2af63c8ed9390bcbf071cdac5.tar.gz pacman-7ee01c86669327b2af63c8ed9390bcbf071cdac5.tar.xz |
_alpm_key_in_keychain: cache known keys
Implements FS#38042
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Diffstat (limited to 'lib/libalpm')
-rw-r--r-- | lib/libalpm/handle.c | 4 | ||||
-rw-r--r-- | lib/libalpm/handle.h | 4 | ||||
-rw-r--r-- | lib/libalpm/signing.c | 6 |
3 files changed, 14 insertions, 0 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index dd284ac5..6545592b 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -71,6 +71,10 @@ void _alpm_handle_free(alpm_handle_t *handle) curl_easy_cleanup(handle->curl); #endif +#ifdef HAVE_LIBGPGME + FREELIST(handle->known_keys); +#endif + regfree(&handle->delta_regex); /* free memory */ diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index b92d3cfb..2888f0f3 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -62,6 +62,10 @@ struct __alpm_handle_t { CURL *curl; /* reusable curl_easy handle */ #endif +#ifdef HAVE_LIBGPGME + alpm_list_t *known_keys; /* keys verified to be in our keychain */ +#endif + /* callback functions */ alpm_cb_log logcb; /* Log callback function */ alpm_cb_download dlcb; /* Download callback function */ diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c index c0fb006e..8391315a 100644 --- a/lib/libalpm/signing.c +++ b/lib/libalpm/signing.c @@ -221,6 +221,11 @@ int _alpm_key_in_keychain(alpm_handle_t *handle, const char *fpr) gpgme_key_t key; int ret = -1; + if(alpm_list_find_str(handle->known_keys, fpr)) { + _alpm_log(handle, ALPM_LOG_DEBUG, "key %s found in cache\n", fpr); + return 1; + } + if(init_gpgme(handle)) { /* pm_errno was set in gpgme_init() */ goto error; @@ -238,6 +243,7 @@ int _alpm_key_in_keychain(alpm_handle_t *handle, const char *fpr) ret = 0; } else if(gpg_err_code(gpg_err) == GPG_ERR_NO_ERROR) { _alpm_log(handle, ALPM_LOG_DEBUG, "key lookup success, key exists\n"); + handle->known_keys = alpm_list_add(handle->known_keys, strdup(fpr)); ret = 1; } else { _alpm_log(handle, ALPM_LOG_DEBUG, "gpg error: %s\n", gpgme_strerror(gpg_err)); |