1 --- crypt-hook-both/PATCHES Dec 2002 17:44:54 -0000 3.6
2 +++ crypt-hook-both/PATCHES Feb 2004 13:19:43 -0000
4 +patch-1.5.6.dw.confirm-crypt-hook.1
5 +patch-1.5.6.dw.multiple-crypt-hook.2
6 --- crypt-hook-both/hook.c Jan 2004 09:52:55 -0000 3.8
7 +++ crypt-hook-both/hook.c Feb 2004 13:19:43 -0000
8 @@ -119,3 +119,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
11 + if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK | M_CRYPTHOOK))
13 if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK))
16 @@ -445,5 +449,21 @@ char *mutt_iconv_hook (const char *chs)
18 -char *mutt_crypt_hook (ADDRESS *adr)
19 +LIST *mutt_crypt_hook (ADDRESS *adr)
21 - return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
23 + LIST *key_list = NULL;
25 + if (!adr && !adr->mailbox)
28 + for (hook = Hooks; hook; hook = hook->next)
32 + if (!(hook->type & M_CRYPTHOOK))
35 + if ((regexec (hook->rx.rx, adr->mailbox, 0, NULL, 0) == 0) ^ hook->rx.not)
36 + key_list = mutt_add_list (key_list, hook->command);
40 --- crypt-hook-both/init.h Feb 2004 17:10:43 -0000 3.43
41 +++ crypt-hook-both/init.h Feb 2004 13:19:43 -0000
42 @@ -1230,2 +1230,11 @@ struct option_t MuttVars[] = {
44 + { "pgp_confirmhook", DT_SYN, R_NONE, UL "crypt_confirmhook", 1 },
45 + { "crypt_confirmhook", DT_BOOL, R_NONE, OPTCRYPTCONFIRMHOOK, 1 },
48 + ** If set, then you will be prompted for confirmation of keys when using
49 + ** the \fIcrypt-hook\fP command. If unset, no such confirmation prompt will
50 + ** be presented. This is generally considered unsafe, especially where
51 + ** typos are concerned.
53 { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
54 --- crypt-hook-both/mutt.h Feb 2004 17:10:43 -0000 3.23
55 +++ crypt-hook-both/mutt.h Feb 2004 13:19:44 -0000
56 @@ -442,2 +442,3 @@ enum
57 OPTSDEFAULTDECRYPTKEY,
58 + OPTCRYPTCONFIRMHOOK,
60 --- crypt-hook-both/pgp.c Sep 2003 13:03:26 -0000 3.26
61 +++ crypt-hook-both/pgp.c Feb 2004 13:19:44 -0000
62 @@ -1018,2 +1018,4 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
63 size_t keylist_used = 0;
64 + LIST *hook_list = NULL;
66 ADDRESS *tmp = NULL, *addr = NULL;
67 @@ -1051,66 +1053,93 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
71 - if ((keyID = mutt_crypt_hook (p)) != NULL)
73 + * grab the list of matching hooks (matching on recipient address)
74 + * process each entry singly so that auto key selection still works
76 + hook_list = mutt_crypt_hook (p);
81 - snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
82 - if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
89 - if (is_numerical_keyid (keyID))
90 + keyID = (char *)hook->data;
91 + snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
92 + if (!option(OPTCRYPTCONFIRMHOOK) || (r = mutt_yesorno (buf, M_YES)) == M_YES)
94 - if (strncmp (keyID, "0x", 2) == 0)
96 - goto bypass_selection; /* you don't see this. */
97 + if (is_numerical_keyid (keyID))
99 + if (strncmp (keyID, "0x", 2) == 0)
101 + goto bypass_selection; /* you don't see this. */
104 + /* check for e-mail address */
105 + if ((t = strchr (keyID, '@')) &&
106 + (addr = rfc822_parse_adrlist (NULL, keyID)))
108 + if (fqdn) rfc822_qualify (addr, fqdn);
112 + k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
115 - /* check for e-mail address */
116 - if ((t = strchr (keyID, '@')) &&
117 - (addr = rfc822_parse_adrlist (NULL, keyID)))
120 - if (fqdn) rfc822_qualify (addr, fqdn);
123 + * yes, this implies that if one key fails they all do
126 + rfc822_free_address (&tmp);
127 + rfc822_free_address (&addr);
128 + mutt_free_list (&hook_list);
132 - k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
137 - rfc822_free_address (&tmp);
138 - rfc822_free_address (&addr);
143 - if (k_info == NULL)
144 - pgp_invoke_getkeys (q);
146 - if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
148 - snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
149 + if (k_info == NULL)
150 + pgp_invoke_getkeys (q);
152 - if ((key = pgp_ask_for_key (buf, q->mailbox,
153 - KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
154 + if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
157 - rfc822_free_address (&tmp);
158 - rfc822_free_address (&addr);
160 + snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
162 + if ((key = pgp_ask_for_key (buf, q->mailbox,
163 + KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
166 + rfc822_free_address (&tmp);
167 + rfc822_free_address (&addr);
168 + mutt_free_list (&hook_list);
178 - keyID = pgp_keyid (key);
179 + keyID = pgp_keyid (key);
182 - keylist_size += mutt_strlen (keyID) + 4;
183 - safe_realloc (&keylist, keylist_size);
184 - sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
186 - keylist_used = mutt_strlen (keylist);
187 + keylist_size += mutt_strlen (keyID) + 4;
188 + safe_realloc (&keylist, keylist_size);
189 + sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
191 + keylist_used = mutt_strlen (keylist);
193 - pgp_free_key (&key);
194 - rfc822_free_address (&addr);
195 + pgp_free_key (&key);
196 + rfc822_free_address (&addr);
206 + mutt_free_list (&hook_list);
208 --- crypt-hook-both/protos.h Feb 2004 17:10:43 -0000 3.19
209 +++ crypt-hook-both/protos.h Feb 2004 13:19:44 -0000
210 @@ -131,3 +131,3 @@ const char *mutt_get_name (ADDRESS *);
211 char *mutt_get_parameter (const char *, PARAMETER *);
212 -char *mutt_crypt_hook (ADDRESS *);
213 +LIST *mutt_crypt_hook (ADDRESS *);
214 char *mutt_make_date (char *, size_t);
215 --- crypt-hook-both/doc/manual.sgml.head Feb 2004 17:45:33 -0000 3.26
216 +++ crypt-hook-both/doc/manual.sgml.head Feb 2004 13:19:44 -0000
217 @@ -1450,3 +1450,5 @@ normally use. The crypt-hook command pr
218 specify the ID of the public key to be used when encrypting messages to
219 -a certain recipient.
220 +a certain recipient. You may use multiple pgp-hook's with the same
221 +pattern; multiple matching pgp-hook's result in the use of multiple
222 +keyids for recipient.
224 --- crypt-hook-both/doc/muttrc.man.head Feb 2004 17:10:43 -0000 3.10
225 +++ crypt-hook-both/doc/muttrc.man.head Feb 2004 13:19:44 -0000
226 @@ -297,3 +297,6 @@ to a certain recipient. The meaning of
227 broadly: This can be a different e-mail address, a numerical key ID,
228 -or even just an arbitrary search string.
229 +or even just an arbitrary search string. You may use multiple
230 +\fBpgp-hook\fPs with the same \fIpattern\fP; multiple matching
231 +\fBpgp-hook\fPs result in the use of multiple \fIkey-id\fPs for