On Sun, Apr 08, 2018 at 03:56:19PM +0100, Julian Gilbey wrote:
> [...]
>
> Since my GPG key is in the Debian keyring, I observe the following:
>
> erdos:~ $ gpg --list-options show-keyring --list-secret-keys
> 0x59D03CC92BA0FEAE
> Keyring: /home/jdg/.gnupg/pubring.gpg
> -------------------------------------
> sec# rsa4096/0x59D03CC92BA0FEAE 2014-10-29 [SC] [expires: 2018-08-23]
> Key fingerprint = 725E 9D6E E56F CAD6 C339 A7F2 59D0 3CC9 2BA0 FEAE
> [...]
>
> Keyring: /usr/share/keyrings/debian-keyring.gpg
> -----------------------------------------------
> sec# rsa4096/0x59D03CC92BA0FEAE 2014-10-29 [SC] [expires: 2018-08-23]
> Key fingerprint = 725E 9D6E E56F CAD6 C339 A7F2 59D0 3CC9 2BA0 FEAE
> [...]
>
> and the same key is reported twice, as the public key is found on two
> separate keyrings.
>
> In the past, mutt had no problem with this, but now, mutt is
> complaining with the message:
>
> ambiguous specification of secret key
> `0x725E9D6EE56FCAD6C339A7F259D03CC92BA0FEAE'?
> [...]
Hello!
I've located and fixed the source of this bug; a patch is attached.
I've also submitted it upstream as
https://gitlab.com/muttmua/mutt/merge_requests/43
Best wishes,
Julian
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -707,6 +707,7 @@
gpgme_error_t err;
gpgme_ctx_t listctx;
gpgme_key_t key, key2;
+ char *fpr, *fpr2;
if (for_smime)
signid = (SmimeSignAs && *SmimeSignAs) ? SmimeSignAs : SmimeDefaultKey;
@@ -727,15 +728,21 @@
signid, gpgme_strerror (err));
return -1;
}
- err = gpgme_op_keylist_next (listctx, &key2);
- if (!err)
+ fpr = key->subkeys->fpr;
+ while (! gpgme_op_keylist_next (listctx, &key2))
{
- gpgme_key_unref (key);
- gpgme_key_unref (key2);
- gpgme_release (listctx);
- mutt_error (_("ambiguous specification of secret key `%s'\n"),
- signid);
- return -1;
+ fpr2 = key2->subkeys->fpr;
+ if (strcmp(fpr, fpr2))
+ {
+ gpgme_key_unref (key);
+ gpgme_key_unref (key2);
+ gpgme_release (listctx);
+ mutt_error (_("ambiguous specification of secret key `%s'\n"),
+ signid);
+ return -1;
+ } else {
+ gpgme_key_unref (key2);
+ }
}
gpgme_op_keylist_end (listctx);
gpgme_release (listctx);