Attached is a patch which introduces two new variables, pgp_autoselectkey and pgp_confirmhook, with defaults of 0/no and 1/yes respectively. The motivation here is that when I use pgp-hook I really don't want to be asked if that's the key I intended to use. Arguably, the confirmation is useful in case I've made a typo, but I think that would still be a one-time check. Similarly, the automatic selection of a key is useful to me since I've (usually) already decided on the correct key with pgp-hook. There is also the case where key selection is obvious based on recipient address. Any chances this will get included into the next/some release of mutt?
regards. -- -Dale
--- init.h 2002/01/02 07:27:09 1.1.1.2 +++ init.h 2002/01/02 19:07:13 @@ -1148,6 +1148,14 @@ #ifdef HAVE_PGP + { "pgp_autoselectkey", DT_BOOL, R_NONE, OPTPGPAUTOSELECT, 0 }, + /* + ** .pp + ** If set, then a list of keys is not presented for selection when only + ** one matching key is available. This may be useful in conjunction with + ** the \fIpgp-hook\fP command (with ``$$pgp_confirmhook'' set) and the + ** ``$$pgp_ignore_subkeys'' variable. + */ { "pgp_autosign", DT_BOOL, R_NONE, OPTPGPAUTOSIGN, 0 }, /* ** .pp @@ -1164,6 +1172,14 @@ ** to the \fIsend-hook\fP command. It can be overridden by use of the ** \fIpgp-menu\fP, when encryption is not required or signing is ** requested as well. + */ + { "pgp_confirmhook", DT_BOOL, R_NONE, OPTPGPCONFIRMHOOK, 1 }, + /* + ** .pp + ** If set, then you will be prompted for confirmation of keys when using + ** the \fIpgp-hook\fP command. If unset, no such confirmation prompt will + ** be presented. This is generally considered unsafe, especially where + ** typos are concerned. */ { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1}, /* --- mutt.h 2002/01/02 07:27:09 1.1.1.2 +++ mutt.h 2002/01/02 08:07:32 @@ -411,8 +411,10 @@ /* PGP options */ #ifdef HAVE_PGP + OPTPGPAUTOSELECT, OPTPGPAUTOSIGN, OPTPGPAUTOENCRYPT, + OPTPGPCONFIRMHOOK, OPTPGPIGNORESUB, OPTPGPLONGIDS, OPTPGPREPLYENCRYPT, --- pgp.c 2001/12/28 07:50:33 1.1.1.1 +++ pgp.c 2002/01/02 06:30:44 @@ -1366,7 +1366,7 @@ { int r; snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox); - if ((r = mutt_yesorno (buf, M_YES)) == M_YES) + if (!option(OPTPGPCONFIRMHOOK) || (r = mutt_yesorno (buf, M_YES)) == M_YES) { /* check for e-mail address */ if ((t = strchr (keyID, '@')) && --- pgpkey.c 2001/12/28 07:50:33 1.1.1.1 +++ pgpkey.c 2002/01/02 19:15:39 @@ -435,6 +435,11 @@ return rv; } + +#define pgp_trusted_key(k) (!option(OPTPGPCHECKTRUST) \ + || (pgp_id_is_valid((k)->address) \ + && pgp_id_is_strong((k)->address))) + static pgp_key_t *pgp_select_key (pgp_key_t *keys, ADDRESS * p, const char *s) { @@ -450,6 +455,7 @@ pgp_uid_t *a; int (*f) (const void *, const void *); + int keymatch = 0; /* count matching keys */ int unusable = 0; keymax = 0; @@ -479,6 +485,7 @@ KeyTable[i++] = a; } + keymatch++; } if (!i && unusable) @@ -487,6 +494,17 @@ mutt_sleep (1); return NULL; } + else if (keymatch == 1 && option(OPTPGPAUTOSELECT) && +pgp_trusted_key(KeyTable[0]->parent)) + { + /* + * In fact, there may be multiple entries in KeyTable even when there is only + * one matching key as there may be many addresses (uids) per key...we select + * the 0th entry, which is actually the last one listed....should be irrelevant + */ + kp = KeyTable[0]->parent; + safe_free ((void **) &KeyTable); + return (kp); + } switch (PgpSortKeys & SORT_MASK) { @@ -597,9 +615,7 @@ break; } - if (option (OPTPGPCHECKTRUST) && - (!pgp_id_is_valid (KeyTable[menu->current]) - || !pgp_id_is_strong (KeyTable[menu->current]))) + if (!pgp_trusted_key(KeyTable[menu->current]->parent)) { char *s = ""; char buff[LONG_STRING];
msg22137/pgp00000.pgp
Description: PGP signature