commit 542830e57d4c2f88cf3be1b14bed7bab45048f9f
parent fb1155139928f18cc6daf150303b779263529145
Author: Colin Leroy <colin@colino.net>
Date: Wed, 26 Nov 2008 17:28:23 +0000
2008-11-26 [colin] 3.6.1cvs45
* src/plugins/pgpcore/select-keys.c
* src/plugins/pgpcore/sgpgme.c
Fix bug 1591, 'S/MIME: better key
handling/selection dialog'
Really ignore revoked/expired keys
Diffstat:
5 files changed, 54 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,11 @@
+2008-11-26 [colin] 3.6.1cvs45
+
+ * src/plugins/pgpcore/select-keys.c
+ * src/plugins/pgpcore/sgpgme.c
+ Fix bug 1591, 'S/MIME: better key
+ handling/selection dialog'
+ Really ignore revoked/expired keys
+
2008-11-26 [colin] 3.6.1cvs44
* src/main.c
diff --git a/PATCHSETS b/PATCHSETS
@@ -3626,3 +3626,4 @@
( cvs diff -u -r 1.49.2.121 -r 1.49.2.122 src/procmime.c; ) > 3.6.1cvs42.patchset
( cvs diff -u -r 1.179.2.236 -r 1.179.2.237 src/imap.c; cvs diff -u -r 1.101.2.57 -r 1.101.2.58 src/news.c; cvs diff -u -r 1.1.4.105 -r 1.1.4.106 src/etpan/imap-thread.c; ) > 3.6.1cvs43.patchset
( cvs diff -u -r 1.115.2.215 -r 1.115.2.216 src/main.c; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/common/claws.c; cvs diff -u -r 1.9.2.35 -r 1.9.2.36 src/common/ssl.c; ) > 3.6.1cvs44.patchset
+( cvs diff -u -r 1.1.2.21 -r 1.1.2.22 src/plugins/pgpcore/select-keys.c; cvs diff -u -r 1.1.2.56 -r 1.1.2.57 src/plugins/pgpcore/sgpgme.c; ) > 3.6.1cvs45.patchset
diff --git a/configure.ac b/configure.ac
@@ -11,7 +11,7 @@ MINOR_VERSION=6
MICRO_VERSION=1
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=44
+EXTRA_VERSION=45
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
diff --git a/src/plugins/pgpcore/select-keys.c b/src/plugins/pgpcore/select-keys.c
@@ -183,8 +183,9 @@ set_row (GtkCMCList *clist, gpgme_key_t key, gpgme_protocol_t proto)
/* first check whether the key is capable of encryption which is not
* the case for revoked, expired or sign-only keys */
- if (!key->can_encrypt)
+ if (!key->can_encrypt || key->revoked || key->expired)
return;
+
algo_buf = g_strdup_printf ("%du/%s",
key->subkeys->length,
gpgme_pubkey_algo_name(key->subkeys->pubkey_algo) );
@@ -235,23 +236,23 @@ set_row (GtkCMCList *clist, gpgme_key_t key, gpgme_protocol_t proto)
switch (key->uids->validity)
{
case GPGME_VALIDITY_UNDEFINED:
- s = "q";
+ s = _("Undefined");
break;
case GPGME_VALIDITY_NEVER:
- s = "n";
+ s = _("Never");
break;
case GPGME_VALIDITY_MARGINAL:
- s = "m";
+ s = _("Marginal");
break;
case GPGME_VALIDITY_FULL:
- s = "f";
+ s = _("Full");
break;
case GPGME_VALIDITY_ULTIMATE:
- s = "u";
+ s = _("Ultimate");
break;
case GPGME_VALIDITY_UNKNOWN:
default:
- s = "?";
+ s = _("Unknown");
break;
}
text[COL_VALIDITY] = s;
@@ -301,7 +302,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot
update_progress (sk, ++running, pattern);
while ( !(err = gpgme_op_keylist_next ( ctx, &key )) ) {
gpgme_user_id_t uid = key->uids;
- if (!key->can_encrypt)
+ if (!key->can_encrypt || key->revoked || key->expired)
continue;
debug_print ("%% %s:%d: insert\n", __FILE__ ,__LINE__ );
set_row (clist, key, proto );
@@ -312,7 +313,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot
continue;
raw_mail = g_strdup(uid->email);
extract_address(raw_mail);
- if (!strcmp(pattern, raw_mail)) {
+ if (!strcasecmp(pattern, raw_mail)) {
exact_match = TRUE;
g_free(raw_mail);
break;
@@ -394,7 +395,7 @@ create_dialog (struct select_keys_s *sk)
titles[COL_KEYID] = _("Key ID");
titles[COL_NAME] = _("Name");
titles[COL_EMAIL] = _("Address");
- titles[COL_VALIDITY] = _("Val");
+ titles[COL_VALIDITY] = _("Trust");
clist = gtk_cmclist_new_with_titles (N_COL_TITLES, (char**)titles);
gtk_container_add (GTK_CONTAINER (scrolledwin), clist);
diff --git a/src/plugins/pgpcore/sgpgme.c b/src/plugins/pgpcore/sgpgme.c
@@ -503,16 +503,44 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account)
goto bail;
err = gpgme_op_keylist_start(ctx, keyid, 1);
- if (!err)
- err = gpgme_op_keylist_next(ctx, &key);
+ if (!err) {
+ do {
+ err = gpgme_op_keylist_next(ctx, &key);
+ if (!err && key && key->protocol == gpgme_get_protocol(ctx) &&
+ !key->expired && !key->revoked)
+ break;
+ if (!err && key && key->protocol != gpgme_get_protocol(ctx)) {
+ debug_print("skipping a key (wrong protocol %d)\n", key->protocol);
+ gpgme_key_release(key);
+ }
+ if (!err && key && (key->expired || key->revoked)) {
+ debug_print("skipping a key (%s)\n", key->expired?"expired":"revoked");
+ gpgme_key_release(key);
+ }
+ } while (!err);
+ }
if (err) {
g_warning("setup_signers start: %s", gpgme_strerror(err));
privacy_set_error(_("Secret key not found (%s)"), gpgme_strerror(err));
goto bail;
}
- err = gpgme_op_keylist_next(ctx, &key2);
+ do {
+ err = gpgme_op_keylist_next(ctx, &key2);
+ if (!err && key2 && key2->protocol == gpgme_get_protocol(ctx) &&
+ !key2->expired && !key2->revoked)
+ break;
+ if (!err && key && key2->protocol != gpgme_get_protocol(ctx)) {
+ debug_print("skipping a key (wrong protocol %d)\n", key2->protocol);
+ gpgme_key_release(key2);
+ }
+ if (!err && key && (key2->expired || key2->revoked)) {
+ debug_print("skipping a key (%s)\n", key2->expired?"expired":"revoked");
+ gpgme_key_release(key2);
+ }
+ } while (!err);
if (!err) {
+ gpgme_key_release(key2);
g_warning("ambiguous specification of secret key '%s'\n",
keyid);
privacy_set_error(_("Secret key specification is ambiguous"));
@@ -521,6 +549,8 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account)
gpgme_op_keylist_end(ctx);
err = gpgme_signers_add(ctx, key);
+ debug_print("got key (proto %d (pgp %d, smime %d).\n", key->protocol,
+ GPGME_PROTOCOL_OpenPGP, GPGME_PROTOCOL_CMS);
gpgme_key_release(key);
if (err) {