From: Kevin McCarthy Date: Sun, 19 Apr 2015 20:15:50 +0000 (-0700) Subject: Add $crypt_confirmhook option. (see #3727) X-Git-Tag: mutt-1-5-24-rel~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d95d561c28d759473f93a6b08b725f0b4f9fc1b9;p=mutt Add $crypt_confirmhook option. (see #3727) Allow the confirmation prompt for crypt-hooks to be disabled. This is useful for multiple crypt-hook users (e.g. encrypted mailing lists), or just for people who are certain of their crypt-hooks and don't want to be prompted every time. Thanks to Dale Woolridge for the original patch. --- diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 7bb1997f..8a39fd9c 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -4386,14 +4386,14 @@ static char *find_keys (ADDRESS *adrlist, unsigned int app, int oppenc_mode) if (crypt_hook != NULL) { crypt_hook_val = crypt_hook->data; - r = M_NO; - if (! oppenc_mode) + r = M_YES; + if (! oppenc_mode && option(OPTCRYPTCONFIRMHOOK)) { snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), crypt_hook_val, p->mailbox); r = mutt_yesorno (buf, M_YES); } - if (oppenc_mode || (r == M_YES)) + if (r == M_YES) { if (crypt_is_numerical_keyid (crypt_hook_val)) { diff --git a/doc/manual.xml.head b/doc/manual.xml.head index cb1ed626..f8d80324 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -3636,9 +3636,10 @@ key to be used when encrypting messages to a certain recipient. You may use multiple crypt-hooks with the same regexp; multiple matching crypt-hooks result in the use of multiple keyids for a recipient. During key selection, Mutt will confirm whether each -crypt-hook is to be used. If all crypt-hooks for a recipient are -declined, Mutt will use the original recipient address for key selection -instead. +crypt-hook is to be used (unless the $crypt_confirmhook option is unset). +If all crypt-hooks for a recipient are declined, Mutt will use the +original recipient address for key selection instead. diff --git a/init.h b/init.h index 9d938f75..9a683b71 100644 --- a/init.h +++ b/init.h @@ -491,6 +491,14 @@ struct option_t MuttVars[] = { ** $$crypt_replyencrypt, ** $$crypt_autosign, $$crypt_replysign and $$smime_is_default. */ + { "crypt_confirmhook", DT_BOOL, R_NONE, OPTCRYPTCONFIRMHOOK, 1 }, + /* + ** .pp + ** If set, then you will be prompted for confirmation of keys when using + ** the \fIcrypt-hook\fP command. If unset, no such confirmation prompt will + ** be presented. This is generally considered unsafe, especially where + ** typos are concerned. + */ { "crypt_opportunistic_encrypt", DT_BOOL, R_NONE, OPTCRYPTOPPORTUNISTICENCRYPT, 0 }, /* ** .pp diff --git a/mutt.h b/mutt.h index 41a3637c..fa8f3c82 100644 --- a/mutt.h +++ b/mutt.h @@ -461,6 +461,7 @@ enum OPTCRYPTAUTOENCRYPT, OPTCRYPTAUTOPGP, OPTCRYPTAUTOSMIME, + OPTCRYPTCONFIRMHOOK, OPTCRYPTOPPORTUNISTICENCRYPT, OPTCRYPTREPLYENCRYPT, OPTCRYPTREPLYSIGN, diff --git a/pgp.c b/pgp.c index 11e42543..1d718861 100644 --- a/pgp.c +++ b/pgp.c @@ -1220,13 +1220,13 @@ char *pgp_findKeys (ADDRESS *adrlist, int oppenc_mode) if (crypt_hook != NULL) { keyID = crypt_hook->data; - r = M_NO; - if (! oppenc_mode) + r = M_YES; + if (! oppenc_mode && option(OPTCRYPTCONFIRMHOOK)) { snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox); r = mutt_yesorno (buf, M_YES); } - if (oppenc_mode || (r == M_YES)) + if (r == M_YES) { if (crypt_is_numerical_keyid (keyID)) {