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 --- mutt-1.5.15/hook.c.orig 2007-06-03 14:10:28.090351677 +0200
7 +++ mutt-1.5.15/hook.c 2007-06-03 14:12:17.468584787 +0200
8 @@ -139,7 +139,11 @@ int mutt_parse_hook (BUFFER *buf, BUFFER
10 !mutt_strcmp (pattern.data, ptr->rx.pattern))
13 + if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK | M_CRYPTHOOK))
15 if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK))
18 /* these hooks allow multiple commands with the same
19 * pattern, so if we've already seen this pattern/command pair, just
20 @@ -466,9 +470,25 @@ char *mutt_iconv_hook (const char *chs)
21 return _mutt_string_hook (chs, M_ICONVHOOK);
24 -char *mutt_crypt_hook (ADDRESS *adr)
25 +LIST *mutt_crypt_hook (ADDRESS *adr)
27 - return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
29 + LIST *key_list = NULL;
31 + if (!adr && !adr->mailbox)
34 + for (hook = Hooks; hook; hook = hook->next)
38 + if (!(hook->type & M_CRYPTHOOK))
41 + if ((regexec (hook->rx.rx, adr->mailbox, 0, NULL, 0) == 0) ^ hook->rx.not)
42 + key_list = mutt_add_list (key_list, hook->command);
48 --- crypt-hook-both/init.h Feb 2004 17:10:43 -0000 3.43
49 +++ crypt-hook-both/init.h Feb 2004 13:19:43 -0000
50 @@ -1230,2 +1230,11 @@ struct option_t MuttVars[] = {
52 + { "pgp_confirmhook", DT_SYN, R_NONE, UL "crypt_confirmhook", 1 },
53 + { "crypt_confirmhook", DT_BOOL, R_NONE, OPTCRYPTCONFIRMHOOK, 1 },
56 + ** If set, then you will be prompted for confirmation of keys when using
57 + ** the \fIcrypt-hook\fP command. If unset, no such confirmation prompt will
58 + ** be presented. This is generally considered unsafe, especially where
59 + ** typos are concerned.
61 { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
62 --- crypt-hook-both/mutt.h Feb 2004 17:10:43 -0000 3.23
63 +++ crypt-hook-both/mutt.h Feb 2004 13:19:44 -0000
64 @@ -442,2 +442,3 @@ enum
65 OPTSDEFAULTDECRYPTKEY,
66 + OPTCRYPTCONFIRMHOOK,
68 --- crypt-hook-both/pgp.c Sep 2003 13:03:26 -0000 3.26
69 +++ crypt-hook-both/pgp.c Feb 2004 13:19:44 -0000
70 @@ -1018,2 +1018,4 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
71 size_t keylist_used = 0;
72 + LIST *hook_list = NULL;
74 ADDRESS *tmp = NULL, *addr = NULL;
75 @@ -1051,66 +1053,93 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
79 - if ((keyID = mutt_crypt_hook (p)) != NULL)
81 + * grab the list of matching hooks (matching on recipient address)
82 + * process each entry singly so that auto key selection still works
84 + hook_list = mutt_crypt_hook (p);
89 - snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
90 - if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
97 - if (is_numerical_keyid (keyID))
98 + keyID = (char *)hook->data;
99 + snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
100 + if (!option(OPTCRYPTCONFIRMHOOK) || (r = mutt_yesorno (buf, M_YES)) == M_YES)
102 - if (strncmp (keyID, "0x", 2) == 0)
104 - goto bypass_selection; /* you don't see this. */
105 + if (is_numerical_keyid (keyID))
107 + if (strncmp (keyID, "0x", 2) == 0)
109 + goto bypass_selection; /* you don't see this. */
112 + /* check for e-mail address */
113 + if ((t = strchr (keyID, '@')) &&
114 + (addr = rfc822_parse_adrlist (NULL, keyID)))
116 + if (fqdn) rfc822_qualify (addr, fqdn);
120 + k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
123 - /* check for e-mail address */
124 - if ((t = strchr (keyID, '@')) &&
125 - (addr = rfc822_parse_adrlist (NULL, keyID)))
128 - if (fqdn) rfc822_qualify (addr, fqdn);
131 + * yes, this implies that if one key fails they all do
134 + rfc822_free_address (&tmp);
135 + rfc822_free_address (&addr);
136 + mutt_free_list (&hook_list);
140 - k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
145 - rfc822_free_address (&tmp);
146 - rfc822_free_address (&addr);
151 - if (k_info == NULL)
152 - pgp_invoke_getkeys (q);
154 - if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
156 - snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
157 + if (k_info == NULL)
158 + pgp_invoke_getkeys (q);
160 - if ((key = pgp_ask_for_key (buf, q->mailbox,
161 - KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
162 + if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
165 - rfc822_free_address (&tmp);
166 - rfc822_free_address (&addr);
168 + snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
170 + if ((key = pgp_ask_for_key (buf, q->mailbox,
171 + KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
174 + rfc822_free_address (&tmp);
175 + rfc822_free_address (&addr);
176 + mutt_free_list (&hook_list);
186 - keyID = pgp_keyid (key);
187 + keyID = pgp_keyid (key);
190 - keylist_size += mutt_strlen (keyID) + 4;
191 - safe_realloc (&keylist, keylist_size);
192 - sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
194 - keylist_used = mutt_strlen (keylist);
195 + keylist_size += mutt_strlen (keyID) + 4;
196 + safe_realloc (&keylist, keylist_size);
197 + sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
199 + keylist_used = mutt_strlen (keylist);
201 - pgp_free_key (&key);
202 - rfc822_free_address (&addr);
203 + pgp_free_key (&key);
204 + rfc822_free_address (&addr);
214 + mutt_free_list (&hook_list);
216 --- crypt-hook-both/protos.h Feb 2004 17:10:43 -0000 3.19
217 +++ crypt-hook-both/protos.h Feb 2004 13:19:44 -0000
218 @@ -131,3 +131,3 @@ const char *mutt_get_name (ADDRESS *);
219 char *mutt_get_parameter (const char *, PARAMETER *);
220 -char *mutt_crypt_hook (ADDRESS *);
221 +LIST *mutt_crypt_hook (ADDRESS *);
222 char *mutt_make_date (char *, size_t);
223 --- crypt-hook-both/doc/manual.xml.head Feb 2004 17:45:33 -0000 3.26
224 +++ crypt-hook-both/doc/manual.xml.head Feb 2004 13:19:44 -0000
225 @@ -1450,3 +1450,5 @@ normally use. The crypt-hook command pr
226 specify the ID of the public key to be used when encrypting messages to
227 -a certain recipient.
228 +a certain recipient. You may use multiple pgp-hook's with the same
229 +pattern; multiple matching pgp-hook's result in the use of multiple
230 +keyids for recipient.
232 --- crypt-hook-both/doc/muttrc.man.head Feb 2004 17:10:43 -0000 3.10
233 +++ crypt-hook-both/doc/muttrc.man.head Feb 2004 13:19:44 -0000
234 @@ -297,3 +297,6 @@ to a certain recipient. The meaning of
235 broadly: This can be a different e-mail address, a numerical key ID,
236 -or even just an arbitrary search string.
237 +or even just an arbitrary search string. You may use multiple
238 +\fBpgp-hook\fPs with the same \fIpattern\fP; multiple matching
239 +\fBpgp-hook\fPs result in the use of multiple \fIkey-id\fPs for