From: Thomas Roessler Date: Fri, 25 Jan 2002 00:06:03 +0000 (+0000) Subject: More decryption key detection fixes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bcfe1f0c3f36ab9c44183e6424acc047ae50a966;p=neomutt More decryption key detection fixes. --- diff --git a/commands.c b/commands.c index 683bae021..2c8f5df47 100644 --- a/commands.c +++ b/commands.c @@ -89,27 +89,7 @@ int mutt_display_message (HEADER *cur) { #ifdef HAVE_SMIME if (cur->security & APPLICATION_SMIME) - { - ADDRESS *t; - int found = 0; - for (t = cur->env->to; !found && t; t = t->next) - if (mutt_addr_is_user (t)) - { - found = 1; - smime_getkeys (t->mailbox); - } - for (t = cur->env->cc; !found && t; t = t->next) - if (mutt_addr_is_user (t)) - { - found = 1; - smime_getkeys (t->mailbox); - } - if (!found && (t = mutt_default_from())) - { - smime_getkeys (t->mailbox); - rfc822_free_address (&t); - } - } + smime_getkeys (cur->env); #endif if(!crypt_valid_passphrase(cur->security)) return 0; diff --git a/recvattach.c b/recvattach.c index 537e09a84..ab6479ede 100644 --- a/recvattach.c +++ b/recvattach.c @@ -878,8 +878,8 @@ void mutt_view_attachments (HEADER *hdr) #ifdef HAVE_SMIME if (hdr->security & APPLICATION_SMIME) { - if (hdr->env->to) - smime_getkeys (hdr->env->to->mailbox); + if (hdr->env) + smime_getkeys (hdr->env); if (mutt_is_application_smime(hdr->content)) secured = ! smime_decrypt_mime (msg->fp, &fp, hdr->content, &cur); diff --git a/smime.c b/smime.c index 27ed36658..9e8aa43c3 100644 --- a/smime.c +++ b/smime.c @@ -663,7 +663,7 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, short m */ static int SmimeFirstTime = 1; /* sucks... */ -void smime_getkeys (char *mailbox) +void _smime_getkeys (char *mailbox) { char *k = smime_get_field_from_db (mailbox, NULL, 0, 0); /* XXX - or sohuld we ask? */ char buf[STRING]; @@ -723,7 +723,29 @@ void smime_getkeys (char *mailbox) NONULL (SmimeCertificates), SmimeSignAs); } +void smime_getkeys (ENVELOPE *env) +{ + ADDRESS *t; + int found = 0; + for (t = env->to; !found && t; t = t->next) + if (mutt_addr_is_user (t)) + { + found = 1; + smime_getkeys (t->mailbox); + } + for (t = env->cc; !found && t; t = t->next) + if (mutt_addr_is_user (t)) + { + found = 1; + smime_getkeys (t->mailbox); + } + if (!found && (t = mutt_default_from())) + { + _smime_getkeys (t->mailbox); + rfc822_free_address (&t); + } +} /* This routine attempts to find the keyids of the recipients of a message. * It returns NULL if any of the keys can not be found. diff --git a/smime.h b/smime.h index 7a6664dc9..49296edd7 100644 --- a/smime.h +++ b/smime.h @@ -78,8 +78,7 @@ char *smime_get_field_from_db (char *, char *, short, short); char* smime_ask_for_key (char *, char *, short); -void smime_getkeys (char *); - +void smime_getkeys (ENVELOPE *); /* private ? */