1 diff -rU3 --new-file mutt-1.3.99-vanilla/PATCHES mutt-1.3.99/PATCHES
2 --- mutt-1.3.99-vanilla/PATCHES Thu May 23 14:12:14 2002
3 +++ mutt-1.3.99/PATCHES Thu May 23 14:13:33 2002
5 +patch-1.3.28.dw.pgp-hook.3
7 patch-1.3.27.cd.signatures_menu.2.1
8 patch-1.3.25.cd.purge_command.2
9 diff -rU3 --new-file mutt-1.3.99-vanilla/doc/manual.sgml.head mutt-1.3.99/doc/manual.sgml.head
10 --- mutt-1.3.99-vanilla/doc/manual.sgml.head Thu May 23 14:12:14 2002
11 +++ mutt-1.3.99/doc/manual.sgml.head Thu May 23 14:13:33 2002
13 or because, for some reasons, you need to override the key Mutt would
14 normally use. The pgp-hook command provides a method by which you can
15 specify the ID of the public key to be used when encrypting messages to
17 +a certain recipient. You may use multiple pgp-hook's with the same
18 +pattern; multiple matching pgp-hook's result in the use of multiple
19 +keyids for recipient.
21 <sect1>Adding key sequences to the keyboard buffer<label id="push">
23 diff -rU3 --new-file mutt-1.3.99-vanilla/doc/muttrc.man.head mutt-1.3.99/doc/muttrc.man.head
24 --- mutt-1.3.99-vanilla/doc/muttrc.man.head Thu May 23 14:12:13 2002
25 +++ mutt-1.3.99/doc/muttrc.man.head Thu May 23 14:15:38 2002
27 \fBpgp-hook\fP \fIpattern\fP \fIkey-id\fP
28 The pgp-hook command provides a method by which you can
29 specify the ID of the public key to be used when encrypting messages
30 -to a certain recipient.
31 +to a certain recipient. You may use multiple \fBpgp-hook\fPs with the
32 +same \fIpattern\fP; multiple matching \fBpgp-hook\fPs result in the use
33 +of multiple \fIkey-id\fPs for recipient.
36 \fBopen-hook\fP \fIregexp\fP "\fIcommand\fP"
37 diff -rU3 --new-file mutt-1.3.99-vanilla/hook.c mutt-1.3.99/hook.c
38 --- mutt-1.3.99-vanilla/hook.c Thu May 23 14:12:13 2002
39 +++ mutt-1.3.99/hook.c Thu May 23 14:13:33 2002
42 !mutt_strcmp (pattern.data, ptr->rx.pattern))
45 + if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_PGPHOOK))
47 if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK))
48 +#endif /* M_PGPHOOK */
50 /* these hooks allow multiple commands with the same
51 * pattern, so if we've already seen this pattern/command pair, just
56 -char *mutt_pgp_hook (ADDRESS *adr)
57 +LIST *mutt_pgp_hook (ADDRESS *adr)
59 - return _mutt_string_hook (adr->mailbox, M_PGPHOOK);
61 + LIST *key_list = NULL;
63 + if (!adr && !adr->mailbox)
66 + for (hook = Hooks; hook; hook = hook->next)
70 + if (!(hook->type & M_PGPHOOK))
73 + if ((regexec (hook->rx.rx, adr->mailbox, 0, NULL, 0) == 0) ^ hook->rx.not)
74 + key_list = mutt_add_list (key_list, hook->command);
80 diff -rU3 --new-file mutt-1.3.99-vanilla/init.h mutt-1.3.99/init.h
81 --- mutt-1.3.99-vanilla/init.h Thu May 23 14:12:14 2002
82 +++ mutt-1.3.99/init.h Thu May 23 14:13:33 2002
83 @@ -1183,6 +1183,14 @@
87 + { "pgp_autoselectkey", DT_BOOL, R_NONE, OPTPGPAUTOSELECT, 0 },
90 + ** If set, then a list of keys is not presented for selection when only
91 + ** one matching key is available. This may be useful in conjunction with
92 + ** the \fIpgp-hook\fP command (with ``$$pgp_confirmhook'' set) and the
93 + ** ``$$pgp_ignore_subkeys'' variable.
95 { "pgp_autosign", DT_BOOL, R_NONE, OPTPGPAUTOSIGN, 0 },
98 @@ -1200,6 +1208,14 @@
99 ** \fIpgp-menu\fP, when encryption is not required or signing is
100 ** requested as well.
102 + { "pgp_confirmhook", DT_BOOL, R_NONE, OPTPGPCONFIRMHOOK, 1 },
105 + ** If set, then you will be prompted for confirmation of keys when using
106 + ** the \fIpgp-hook\fP command. If unset, no such confirmation prompt will
107 + ** be presented. This is generally considered unsafe, especially where
108 + ** typos are concerned.
110 { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
113 diff -rU3 --new-file mutt-1.3.99-vanilla/mutt-1.3.28/PATCHES mutt-1.3.99/mutt-1.3.28/PATCHES
114 --- mutt-1.3.99-vanilla/mutt-1.3.28/PATCHES Thu Jan 1 01:00:00 1970
115 +++ mutt-1.3.99/mutt-1.3.28/PATCHES Thu May 23 14:13:28 2002
117 +patch-1.3.28.dw.pgp-hook.3
118 diff -rU3 --new-file mutt-1.3.99-vanilla/mutt.h mutt-1.3.99/mutt.h
119 --- mutt-1.3.99-vanilla/mutt.h Thu May 23 14:12:14 2002
120 +++ mutt-1.3.99/mutt.h Thu May 23 14:13:33 2002
132 diff -rU3 --new-file mutt-1.3.99-vanilla/pgp.c mutt-1.3.99/pgp.c
133 --- mutt-1.3.99-vanilla/pgp.c Wed Jan 9 16:39:28 2002
134 +++ mutt-1.3.99/pgp.c Thu May 23 14:13:33 2002
135 @@ -1327,6 +1327,8 @@
136 char *keyID, *keylist = NULL, *t;
137 size_t keylist_size = 0;
138 size_t keylist_used = 0;
139 + LIST *hook_list = NULL;
141 ADDRESS *tmp = NULL, *addr = NULL;
142 ADDRESS **last = &tmp;
144 @@ -1360,62 +1362,88 @@
145 char buf[LONG_STRING];
150 - if ((keyID = mutt_pgp_hook (p)) != NULL)
152 + * grab the list of matching hooks (matching on recipient address)
153 + * process each entry singly so that auto key selection still works
155 + hook_list = mutt_pgp_hook (p);
160 - snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
161 - if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
167 - /* check for e-mail address */
168 - if ((t = strchr (keyID, '@')) &&
169 - (addr = rfc822_parse_adrlist (NULL, keyID)))
170 + keyID = (char *)hook->data;
171 + snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
172 + if (!option(OPTPGPCONFIRMHOOK) || (r = mutt_yesorno (buf, M_YES)) == M_YES)
174 - if (fqdn) rfc822_qualify (addr, fqdn);
176 + /* check for e-mail address */
177 + if ((t = strchr (keyID, '@')) &&
178 + (addr = rfc822_parse_adrlist (NULL, keyID)))
180 + if (fqdn) rfc822_qualify (addr, fqdn);
184 + k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
189 + * yes, this implies that if one key fails they all do
191 + safe_free ((void **) &keylist);
192 + rfc822_free_address (&tmp);
193 + rfc822_free_address (&addr);
194 + mutt_free_list (&hook_list);
198 - k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
202 - safe_free ((void **) &keylist);
203 - rfc822_free_address (&tmp);
204 - rfc822_free_address (&addr);
209 - if (k_info == NULL)
210 - pgp_invoke_getkeys (q);
211 + if (k_info == NULL)
212 + pgp_invoke_getkeys (q);
214 - if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
216 - snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
218 - if ((key = pgp_ask_for_key (buf, q->mailbox,
219 - KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
220 + if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
222 - safe_free ((void **)&keylist);
223 - rfc822_free_address (&tmp);
224 - rfc822_free_address (&addr);
226 + snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
228 + if ((key = pgp_ask_for_key (buf, q->mailbox,
229 + KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
231 + safe_free ((void **)&keylist);
232 + rfc822_free_address (&tmp);
233 + rfc822_free_address (&addr);
234 + mutt_free_list (&hook_list);
244 - keyID = pgp_keyid (key);
246 - keylist_size += mutt_strlen (keyID) + 4;
247 - safe_realloc ((void **)&keylist, keylist_size);
248 - sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
250 - keylist_used = mutt_strlen (keylist);
251 + keyID = pgp_keyid (key);
253 + keylist_size += mutt_strlen (keyID) + 4;
254 + safe_realloc ((void **)&keylist, keylist_size);
255 + sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
257 + keylist_used = mutt_strlen (keylist);
259 + pgp_free_key (&key);
260 + rfc822_free_address (&addr);
269 - pgp_free_key (&key);
270 - rfc822_free_address (&addr);
272 + mutt_free_list (&hook_list);
275 rfc822_free_address (&tmp);
276 diff -rU3 --new-file mutt-1.3.99-vanilla/pgpkey.c mutt-1.3.99/pgpkey.c
277 --- mutt-1.3.99-vanilla/pgpkey.c Tue Jan 15 10:04:28 2002
278 +++ mutt-1.3.99/pgpkey.c Thu May 23 14:13:33 2002
284 +#define pgp_trusted_id(uid) (!option(OPTPGPCHECKTRUST) \
285 + || (pgp_id_is_valid((uid)) \
286 + && pgp_id_is_strong((uid))))
288 static pgp_key_t *pgp_select_key (pgp_key_t *keys,
289 ADDRESS * p, const char *s)
293 int (*f) (const void *, const void *);
295 + int keymatch = 0; /* count matching keys */
311 + else if (keymatch == 1 && option(OPTPGPAUTOSELECT))
314 + * Only one matching key...see if there's an id with enough trust to auto-select
316 + kp = KeyTable[0]->parent;
317 + for (a = kp->address; a; a = a->next)
319 + if (pgp_trusted_id(a))
321 + safe_free ((void **) &KeyTable);
327 switch (PgpSortKeys & SORT_MASK)
333 - if (option (OPTPGPCHECKTRUST) &&
334 - (!pgp_id_is_valid (KeyTable[menu->current])
335 - || !pgp_id_is_strong (KeyTable[menu->current])))
336 + if (!pgp_trusted_id(KeyTable[menu->current]))
339 char buff[LONG_STRING];
340 diff -rU3 --new-file mutt-1.3.99-vanilla/protos.h mutt-1.3.99/protos.h
341 --- mutt-1.3.99-vanilla/protos.h Thu May 23 14:12:14 2002
342 +++ mutt-1.3.99/protos.h Thu May 23 14:13:33 2002
344 char *mutt_get_name (ADDRESS *);
345 char *mutt_get_parameter (const char *, PARAMETER *);
347 -char *mutt_pgp_hook (ADDRESS *);
348 +LIST *mutt_pgp_hook (ADDRESS *);
349 #endif /* HAVE_PGP */
350 char *mutt_make_date (char *, size_t);