mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
signing: cope with gpg2's failure at life
For key searches only, gpg2 will fail to lookup any and all keys that are not prefixed with 0x. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
f988aa6b32
commit
be0e044404
@ -234,6 +234,14 @@ static int key_search(alpm_handle_t *handle, const char *fpr,
|
|||||||
gpgme_keylist_mode_t mode;
|
gpgme_keylist_mode_t mode;
|
||||||
gpgme_key_t key;
|
gpgme_key_t key;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
size_t fpr_len;
|
||||||
|
char *full_fpr;
|
||||||
|
|
||||||
|
/* gpg2 goes full retard here. For key searches ONLY, we need to prefix the
|
||||||
|
* key fingerprint with 0x, or the lookup will fail. */
|
||||||
|
fpr_len = strlen(fpr);
|
||||||
|
MALLOC(full_fpr, fpr_len + 3, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
|
||||||
|
sprintf(full_fpr, "0x%s", fpr);
|
||||||
|
|
||||||
memset(&ctx, 0, sizeof(ctx));
|
memset(&ctx, 0, sizeof(ctx));
|
||||||
err = gpgme_new(&ctx);
|
err = gpgme_new(&ctx);
|
||||||
@ -248,14 +256,14 @@ static int key_search(alpm_handle_t *handle, const char *fpr,
|
|||||||
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "looking up key %s remotely\n", fpr);
|
_alpm_log(handle, ALPM_LOG_DEBUG, "looking up key %s remotely\n", fpr);
|
||||||
|
|
||||||
err = gpgme_get_key(ctx, fpr, &key, 0);
|
err = gpgme_get_key(ctx, full_fpr, &key, 0);
|
||||||
if(gpg_err_code(err) == GPG_ERR_EOF) {
|
if(gpg_err_code(err) == GPG_ERR_EOF) {
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "key lookup failed, unknown key\n");
|
_alpm_log(handle, ALPM_LOG_DEBUG, "key lookup failed, unknown key\n");
|
||||||
/* Try an alternate lookup using the 8 character fingerprint value, since
|
/* Try an alternate lookup using the 8 character fingerprint value, since
|
||||||
* busted-ass keyservers can't support lookups using subkeys with the full
|
* busted-ass keyservers can't support lookups using subkeys with the full
|
||||||
* value as of now. This is why 2012 is not the year of PGP encryption. */
|
* value as of now. This is why 2012 is not the year of PGP encryption. */
|
||||||
if(strlen(fpr) > 8) {
|
if(fpr_len > 8) {
|
||||||
const char *short_fpr = fpr + strlen(fpr) - 8;
|
const char *short_fpr = memcpy(&full_fpr[fpr_len - 8], "0x", 2);
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG,
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
||||||
"looking up key %s remotely\n", short_fpr);
|
"looking up key %s remotely\n", short_fpr);
|
||||||
err = gpgme_get_key(ctx, short_fpr, &key, 0);
|
err = gpgme_get_key(ctx, short_fpr, &key, 0);
|
||||||
@ -289,6 +297,7 @@ static int key_search(alpm_handle_t *handle, const char *fpr,
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "gpg error: %s\n", gpgme_strerror(err));
|
_alpm_log(handle, ALPM_LOG_DEBUG, "gpg error: %s\n", gpgme_strerror(err));
|
||||||
|
free(full_fpr);
|
||||||
gpgme_release(ctx);
|
gpgme_release(ctx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user