From 24d2159ffe28cf940ab36fd53ec527173f4d41d0 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Mon, 12 Jun 2017 17:57:05 -0700 Subject: [PATCH] Make GPGME key selection behavior the same as classic-PGP. (see #3950) Classic-PGP key selection auto-selected a match if there was a single strong, valid, address-match result, even if there were other weak matches. GPGME was prompting in the same situation, if there were other weak matches. Change GPGME to match the classic behavior, as this is more useful and matches the manual description. --- crypt-gpgme.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 885509c85..61f8d8a77 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -4154,14 +4154,9 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, ADDRESS *r, *p; LIST *hints = NULL; - int weak = 0; - int invalid = 0; - int addr_match = 0; int multi = 0; int this_key_has_strong; int this_key_has_addr_match; - int this_key_has_weak; - int this_key_has_invalid; int match; crypt_key_t *keys, *k; @@ -4201,8 +4196,6 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, continue; } - this_key_has_weak = 0; /* weak but valid match */ - this_key_has_invalid = 0; /* invalid match */ this_key_has_strong = 0; /* strong and valid match */ this_key_has_addr_match = 0; match = 0; /* any match */ @@ -4216,9 +4209,8 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, { match = 1; - if (validity & CRYPT_KV_VALID) - { - if (validity & CRYPT_KV_ADDR) + if ((validity & CRYPT_KV_VALID) && + (validity & CRYPT_KV_ADDR)) { if (validity & CRYPT_KV_STRONGID) { @@ -4230,11 +4222,6 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, else this_key_has_addr_match = 1; } - else - this_key_has_weak = 1; - } - else - this_key_has_invalid = 1; } } rfc822_free_address (&r); @@ -4249,14 +4236,7 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, if (this_key_has_strong) the_strong_valid_key = tmp; else if (this_key_has_addr_match) - { - addr_match = 1; a_valid_addrmatch_key = tmp; - } - else if (this_key_has_invalid) - invalid = 1; - else if (this_key_has_weak) - weak = 1; } } @@ -4273,13 +4253,10 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities, else k = NULL; } - else if (the_strong_valid_key && !multi && !weak && !addr_match - && !(invalid && option (OPTPGPSHOWUNUSABLE))) + else if (the_strong_valid_key && !multi) { /* - * 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. + * There was precisely one strong match on a valid ID. * * Proceed without asking the user. */ -- 2.50.0