* Moritz Schulte <Moritz.Schulte@xxxxxxxxxxxxxxxxxx> [2006-04-04 08:47]: > On Mon, 2006-04-03 at 17:43 +0200, Alex Pleiner wrote: > > If I write to "Alex Pleiner <alex@xxxxxxxxxxx>" or even > > "<alex@xxxxxxxxxxx"> I get to the pgp menu with all those above > > entries and have to manually select the right one. Is this correct > > behaviour? > Hm, at first glance this seems wrong - I'll look into this. List members, Moritz, I have tried myself and started to read the code. 1. pgpkey.c versus crypt-gpgme.c --------------------------------------- in pgpkey.c I found: if (matches) { if (the_valid_key && !multi /* && !weak && !(invalid && option (OPTPGPSHOWUNUSABLE)) */) { /* * There was precisely one strong match on a valid ID. * * Proceed without asking the user. */ while gpgme.c reads: if (matches) { if (the_valid_key && !multi && !weak && !(invalid && option (OPTPGPSHOWUNUSABLE))) { /* * There was precisely one strong match on a valid ID, there * were no valid keys with weak matches, and we aren't * interested in seeing invalid keys. * * Proceed without asking the user. */ After changing the latter to match the first, I have noticed that I don't get a pgp menu if I use the first address within the recipient's key, but for all others I still get the pgp menu. Hmm. Playing with debug output I found out that pgp_get_candidates(keyring, hints) returns 1 key while get_candidates(hints, app, (abilities & KEYFLAG_CANSIGN) ) return one for every address within the key. As a conseqence if (the_valid_key && the_valid_key != k) multi = 1; spits into my soup. So I digged further and tried the following: 2. gnupgparse.c versus crypt-gpgme.c ---------------------------------------- In gnupgparse.c I found an interesting comment in pgp_get_candidates /* Only append kk to the list if it's new. */ if (kk != k) To me this look like some keys are skipped. With my limited skills I changed crypt-gpgme.c for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) { k = safe_calloc (1, sizeof *k); k->kobj = key; k->idx = idx; k->uid = uid->uid; k->flags = flags; *kend = k; kend = &k->next; } to something I believe is similar (see attached patch). I am absolutly certain that this is not the best way to solve the problem, but at least it seems to work. Could someone please look at this and give me some insight. Thanks. Alex -- Alex Pleiner zeitform Internet Dienste mailto:pleiner@xxxxxxxxxxx Fraunhoferstraße 5 PGP S/MIME: http://key.zeitform.de/ap 64283 Darmstadt, Germany Tel./Fax: +49 (0) 6151 155-635 / -634 http://www.zeitform.de Jabber: pleiner@xxxxxxxxxx
--- crypt-gpgme.c.orig 2006-04-25 17:45:04.000000000 +0200 +++ crypt-gpgme.c 2006-04-25 20:12:03.000000000 +0200 @@ -3314,7 +3314,7 @@ Select by looking at the HINTS list. */ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret) { - crypt_key_t *db, *k, **kend; + crypt_key_t *db, *k, *kk, **kend; char *pattern; gpgme_error_t err; gpgme_ctx_t ctx; @@ -3405,17 +3405,20 @@ } } #endif /* DISABLED code */ - + kk = NULL;k = NULL; for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) { + /* Only append kk to the list if it's new. */ + if (!kk || k != kk) { k = safe_calloc (1, sizeof *k); k->kobj = key; k->idx = idx; k->uid = uid->uid; k->flags = flags; - *kend = k; + *kend = kk = k; kend = &k->next; } + } } if (gpg_err_code (err) != GPG_ERR_EOF) mutt_error (_("gpgme_op_keylist_next failed: %s"), gpgme_strerror (err)); @@ -3799,8 +3802,8 @@ if (matches) { - if (the_valid_key && !multi && !weak - && !(invalid && option (OPTPGPSHOWUNUSABLE))) + if (the_valid_key && !multi /* && !weak + && !(invalid && option (OPTPGPSHOWUNUSABLE)) */) { /* * There was precisely one strong match on a valid ID, there
Attachment:
pgpTlBsnZW7JR.pgp
Description: PGP signature