]>
Commit | Line | Data |
---|---|---|
984cd593 JB |
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 | |
4 | @@ -1,3 +1,4 @@ | |
5 | +patch-1.3.28.dw.pgp-hook.3 | |
6 | vvv.quote | |
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 | |
12 | @@ -1389,7 +1389,9 @@ | |
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 | |
16 | -a certain recipient. | |
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. | |
20 | ||
21 | <sect1>Adding key sequences to the keyboard buffer<label id="push"> | |
22 | <p> | |
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 | |
1d12b69c | 26 | @@ -257,7 +257,9 @@ |
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. | |
984cd593 JB |
34 | .PP |
35 | .nf | |
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 | |
40 | @@ -129,7 +129,11 @@ | |
41 | ptr->rx.not == not && | |
42 | !mutt_strcmp (pattern.data, ptr->rx.pattern)) | |
43 | { | |
44 | +#ifdef M_PGPHOOK | |
45 | + if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_PGPHOOK)) | |
46 | +#else | |
47 | if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK)) | |
48 | +#endif /* M_PGPHOOK */ | |
49 | { | |
50 | /* these hooks allow multiple commands with the same | |
51 | * pattern, so if we've already seen this pattern/command pair, just | |
52 | @@ -456,9 +460,25 @@ | |
53 | } | |
54 | ||
55 | #ifdef HAVE_PGP | |
56 | -char *mutt_pgp_hook (ADDRESS *adr) | |
57 | +LIST *mutt_pgp_hook (ADDRESS *adr) | |
58 | { | |
59 | - return _mutt_string_hook (adr->mailbox, M_PGPHOOK); | |
60 | + HOOK *hook; | |
61 | + LIST *key_list = NULL; | |
62 | + | |
63 | + if (!adr && !adr->mailbox) | |
64 | + return (NULL); | |
65 | + | |
66 | + for (hook = Hooks; hook; hook = hook->next) | |
67 | + { | |
68 | + if (!hook->command) | |
69 | + continue; | |
70 | + if (!(hook->type & M_PGPHOOK)) | |
71 | + continue; | |
72 | + | |
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); | |
75 | + } | |
76 | + return (key_list); | |
77 | } | |
78 | #endif /* HAVE_PGP */ | |
79 | ||
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 @@ | |
84 | ||
85 | #ifdef HAVE_PGP | |
86 | ||
87 | + { "pgp_autoselectkey", DT_BOOL, R_NONE, OPTPGPAUTOSELECT, 0 }, | |
88 | + /* | |
89 | + ** .pp | |
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. | |
94 | + */ | |
95 | { "pgp_autosign", DT_BOOL, R_NONE, OPTPGPAUTOSIGN, 0 }, | |
96 | /* | |
97 | ** .pp | |
98 | @@ -1200,6 +1208,14 @@ | |
99 | ** \fIpgp-menu\fP, when encryption is not required or signing is | |
100 | ** requested as well. | |
101 | */ | |
102 | + { "pgp_confirmhook", DT_BOOL, R_NONE, OPTPGPCONFIRMHOOK, 1 }, | |
103 | + /* | |
104 | + ** .pp | |
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. | |
109 | + */ | |
110 | { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1}, | |
111 | /* | |
112 | ** .pp | |
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 | |
116 | @@ -0,0 +1 @@ | |
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 | |
121 | @@ -427,8 +427,10 @@ | |
122 | /* PGP options */ | |
123 | ||
124 | #ifdef HAVE_PGP | |
125 | + OPTPGPAUTOSELECT, | |
126 | OPTPGPAUTOSIGN, | |
127 | OPTPGPAUTOENCRYPT, | |
128 | + OPTPGPCONFIRMHOOK, | |
129 | OPTPGPIGNORESUB, | |
130 | OPTPGPLONGIDS, | |
131 | OPTPGPREPLYENCRYPT, | |
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; | |
140 | + LIST *hook = NULL; | |
141 | ADDRESS *tmp = NULL, *addr = NULL; | |
142 | ADDRESS **last = &tmp; | |
143 | ADDRESS *p, *q; | |
144 | @@ -1360,62 +1362,88 @@ | |
145 | char buf[LONG_STRING]; | |
146 | ||
147 | q = p; | |
148 | - k_info = NULL; | |
149 | ||
150 | - if ((keyID = mutt_pgp_hook (p)) != NULL) | |
151 | + /* | |
152 | + * grab the list of matching hooks (matching on recipient address) | |
153 | + * process each entry singly so that auto key selection still works | |
154 | + */ | |
155 | + hook_list = mutt_pgp_hook (p); | |
156 | + hook = hook_list; | |
157 | + while (1) | |
158 | { | |
159 | int r; | |
160 | - snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox); | |
161 | - if ((r = mutt_yesorno (buf, M_YES)) == M_YES) | |
162 | + | |
163 | + k_info = NULL; | |
164 | + | |
165 | + if (hook) | |
166 | { | |
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) | |
173 | { | |
174 | - if (fqdn) rfc822_qualify (addr, fqdn); | |
175 | - q = addr; | |
176 | + /* check for e-mail address */ | |
177 | + if ((t = strchr (keyID, '@')) && | |
178 | + (addr = rfc822_parse_adrlist (NULL, keyID))) | |
179 | + { | |
180 | + if (fqdn) rfc822_qualify (addr, fqdn); | |
181 | + q = addr; | |
182 | + } | |
183 | + else | |
184 | + k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING); | |
185 | + } | |
186 | + else if (r == -1) | |
187 | + { | |
188 | + /* | |
189 | + * yes, this implies that if one key fails they all do | |
190 | + */ | |
191 | + safe_free ((void **) &keylist); | |
192 | + rfc822_free_address (&tmp); | |
193 | + rfc822_free_address (&addr); | |
194 | + mutt_free_list (&hook_list); | |
195 | + return NULL; | |
196 | } | |
197 | - else | |
198 | - k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING); | |
199 | - } | |
200 | - else if (r == -1) | |
201 | - { | |
202 | - safe_free ((void **) &keylist); | |
203 | - rfc822_free_address (&tmp); | |
204 | - rfc822_free_address (&addr); | |
205 | - return NULL; | |
206 | } | |
207 | - } | |
208 | ||
209 | - if (k_info == NULL) | |
210 | - pgp_invoke_getkeys (q); | |
211 | + if (k_info == NULL) | |
212 | + pgp_invoke_getkeys (q); | |
213 | ||
214 | - if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL) | |
215 | - { | |
216 | - snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox); | |
217 | - | |
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) | |
221 | { | |
222 | - safe_free ((void **)&keylist); | |
223 | - rfc822_free_address (&tmp); | |
224 | - rfc822_free_address (&addr); | |
225 | - return NULL; | |
226 | + snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox); | |
227 | + | |
228 | + if ((key = pgp_ask_for_key (buf, q->mailbox, | |
229 | + KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL) | |
230 | + { | |
231 | + safe_free ((void **)&keylist); | |
232 | + rfc822_free_address (&tmp); | |
233 | + rfc822_free_address (&addr); | |
234 | + mutt_free_list (&hook_list); | |
235 | + return NULL; | |
236 | + } | |
237 | } | |
238 | - } | |
239 | - else | |
240 | - key = k_info; | |
241 | + else | |
242 | + key = k_info; | |
243 | ||
244 | - keyID = pgp_keyid (key); | |
245 | - | |
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__ */ | |
249 | - keyID); | |
250 | - keylist_used = mutt_strlen (keylist); | |
251 | + keyID = pgp_keyid (key); | |
252 | + | |
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__ */ | |
256 | + keyID); | |
257 | + keylist_used = mutt_strlen (keylist); | |
258 | + | |
259 | + pgp_free_key (&key); | |
260 | + rfc822_free_address (&addr); | |
261 | + | |
262 | + if (!hook_list) | |
263 | + break; | |
264 | + | |
265 | + hook = hook->next; | |
266 | + if (!hook) | |
267 | + break; | |
268 | ||
269 | - pgp_free_key (&key); | |
270 | - rfc822_free_address (&addr); | |
271 | + } | |
272 | + mutt_free_list (&hook_list); | |
273 | ||
274 | } | |
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 | |
279 | @@ -435,6 +435,11 @@ | |
280 | return rv; | |
281 | } | |
282 | ||
283 | + | |
284 | +#define pgp_trusted_id(uid) (!option(OPTPGPCHECKTRUST) \ | |
285 | + || (pgp_id_is_valid((uid)) \ | |
286 | + && pgp_id_is_strong((uid)))) | |
287 | + | |
288 | static pgp_key_t *pgp_select_key (pgp_key_t *keys, | |
289 | ADDRESS * p, const char *s) | |
290 | { | |
291 | @@ -450,6 +455,7 @@ | |
292 | pgp_uid_t *a; | |
293 | int (*f) (const void *, const void *); | |
294 | ||
295 | + int keymatch = 0; /* count matching keys */ | |
296 | int unusable = 0; | |
297 | ||
298 | keymax = 0; | |
299 | @@ -479,6 +485,7 @@ | |
300 | ||
301 | KeyTable[i++] = a; | |
302 | } | |
303 | + keymatch++; | |
304 | } | |
305 | ||
306 | if (!i && unusable) | |
307 | @@ -487,6 +494,21 @@ | |
308 | mutt_sleep (1); | |
309 | return NULL; | |
310 | } | |
311 | + else if (keymatch == 1 && option(OPTPGPAUTOSELECT)) | |
312 | + { | |
313 | + /* | |
314 | + * Only one matching key...see if there's an id with enough trust to auto-select | |
315 | + */ | |
316 | + kp = KeyTable[0]->parent; | |
317 | + for (a = kp->address; a; a = a->next) | |
318 | + { | |
319 | + if (pgp_trusted_id(a)) | |
320 | + { | |
321 | + safe_free ((void **) &KeyTable); | |
322 | + return (kp); | |
323 | + } | |
324 | + } | |
325 | + } | |
326 | ||
327 | switch (PgpSortKeys & SORT_MASK) | |
328 | { | |
329 | @@ -597,9 +619,7 @@ | |
330 | break; | |
331 | } | |
332 | ||
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])) | |
337 | { | |
338 | char *s = ""; | |
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 | |
343 | @@ -130,7 +130,7 @@ | |
344 | char *mutt_get_name (ADDRESS *); | |
345 | char *mutt_get_parameter (const char *, PARAMETER *); | |
346 | #ifdef HAVE_PGP | |
347 | -char *mutt_pgp_hook (ADDRESS *); | |
348 | +LIST *mutt_pgp_hook (ADDRESS *); | |
349 | #endif /* HAVE_PGP */ | |
350 | char *mutt_make_date (char *, size_t); | |
351 |