This gpgme wasn't setting the usability flags when querying
get_candidates().  This patch adds those (for the pgp branch).

-Kevin
# HG changeset patch
# User Kevin McCarthy <[email protected]>
# Date 1423431850 28800
#      Sun Feb 08 13:44:10 2015 -0800
# Node ID 7162033d1fb8a3b054244fc8097ab8b5bb5a99ed
# Parent  2fd1b9f17b80c2e7813515e4ebaef5a8d61103ac
Fix pgp-gpgme to set revoke/expired/disabled flags.

The code wasn't settings those flags in get_candidates().
This patch adds it to the pgp path.  I don't know if these flags apply
to SMIME so am leaving them out for the smime branch.

Fix up crypt_select_key() to follow the same logic as pgp_select_key().

diff --git a/crypt-gpgme.c b/crypt-gpgme.c
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -3746,16 +3746,23 @@
         {
           unsigned int flags = 0;
          
          if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT))
             flags |= KEYFLAG_CANENCRYPT;
          if (key_check_cap (key, KEY_CAP_CAN_SIGN))
             flags |= KEYFLAG_CANSIGN;
 
+          if (key->revoked)
+            flags |= KEYFLAG_REVOKED;
+          if (key->expired)
+            flags |= KEYFLAG_EXPIRED;
+          if (key->disabled)
+            flags |= KEYFLAG_DISABLED;
+
 #if 0 /* DISABLED code */
           if (!flags)
             {
              /* Bug in gpg.  Capabilities are not listed for secret
                 keys.  Try to deduce them from the algorithm. */
 
              switch (key->subkeys[0].pubkey_algo)
                 {
@@ -3776,16 +3783,18 @@
          for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
             {
               k = safe_calloc (1, sizeof *k);
               k->kobj = key;
               gpgme_key_ref (k->kobj);
               k->idx = idx;
               k->uid = uid->uid;
               k->flags = flags;
+              if (uid->revoked)
+                k->flags |= KEYFLAG_REVOKED;
               *kend = k;
               kend = &k->next;
             }
           gpgme_key_unref (key);
         }
       if (gpg_err_code (err) != GPG_ERR_EOF)
         mutt_error (_("gpgme_op_keylist_next failed: %s"), gpgme_strerror 
(err));
       gpgme_op_keylist_end (ctx);
@@ -3998,17 +4007,17 @@
           if (option (OPTPGPCHECKTRUST) &&
               (!crypt_id_is_valid (key_table[menu->current])
                || !crypt_id_is_strong (key_table[menu->current])))
             {
               const char *warn_s;
               char buff[LONG_STRING];
               
               if (key_table[menu->current]->flags & KEYFLAG_CANTUSE)
-                s = N_("ID is expired/disabled/revoked.");
+                warn_s = N_("ID is expired/disabled/revoked.");
               else 
                 {
                  gpgme_validity_t val = GPGME_VALIDITY_UNKNOWN;
                  gpgme_user_id_t uid = NULL;
                  unsigned int j = 0;
 
                   warn_s = "??";
 
@@ -4030,28 +4039,28 @@
                       break;
                     case GPGME_VALIDITY_MARGINAL:  
                       warn_s = N_("ID is only marginally valid.");
                       break;
                     case GPGME_VALIDITY_FULL:      
                     case GPGME_VALIDITY_ULTIMATE:  
                       break;
                     }
-
-                  snprintf (buff, sizeof (buff),
-                            _("%s Do you really want to use the key?"),
-                            _(warn_s));
-                 
-                  if (mutt_yesorno (buff, 0) != 1)
-                    {
-                      mutt_clear_error ();
-                      break;
-                    }
-                  *forced_valid = 1;
                 }
+
+              snprintf (buff, sizeof (buff),
+                        _("%s Do you really want to use the key?"),
+                        _(warn_s));
+              
+              if (mutt_yesorno (buff, 0) != 1)
+                {
+                  mutt_clear_error ();
+                  break;
+                }
+              *forced_valid = 1;
             }  
 
           k = crypt_copy_key (key_table[menu->current]);
           done = 1;
           break;
           
         case OP_EXIT:
           k = NULL;

Attachment: signature.asc
Description: PGP signature

Reply via email to