]> git.pld-linux.org Git - packages/mutt.git/blame - mutt-pgp_hook.patch
- updated from http://www.woolridge.ca/mutt/patches/patch-1.5.6.dw.crypt-hook-both.1
[packages/mutt.git] / mutt-pgp_hook.patch
CommitLineData
9d38a728
JB
1--- crypt-hook-both/PATCHES Dec 2002 17:44:54 -0000 3.6
2+++ crypt-hook-both/PATCHES Feb 2004 13:19:43 -0000
3@@ -0,0 +1,2 @@
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
984cd593 9 {
9d38a728
JB
10+#ifdef M_CRYPTHOOK
11+ if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK | M_CRYPTHOOK))
984cd593 12+#else
9d38a728
JB
13 if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK))
14+#endif
984cd593 15 {
9d38a728 16@@ -445,5 +449,21 @@ char *mutt_iconv_hook (const char *chs)
984cd593 17
9d38a728
JB
18-char *mutt_crypt_hook (ADDRESS *adr)
19+LIST *mutt_crypt_hook (ADDRESS *adr)
984cd593 20 {
9d38a728 21- return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
984cd593
JB
22+ HOOK *hook;
23+ LIST *key_list = NULL;
24+
25+ if (!adr && !adr->mailbox)
26+ return (NULL);
27+
28+ for (hook = Hooks; hook; hook = hook->next)
29+ {
30+ if (!hook->command)
31+ continue;
9d38a728 32+ if (!(hook->type & M_CRYPTHOOK))
984cd593
JB
33+ continue;
34+
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);
37+ }
38+ return (key_list);
39 }
9d38a728
JB
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[] = {
984cd593 43 */
9d38a728
JB
44+ { "pgp_confirmhook", DT_SYN, R_NONE, UL "crypt_confirmhook", 1 },
45+ { "crypt_confirmhook", DT_BOOL, R_NONE, OPTCRYPTCONFIRMHOOK, 1 },
984cd593
JB
46+ /*
47+ ** .pp
48+ ** If set, then you will be prompted for confirmation of keys when using
9d38a728 49+ ** the \fIcrypt-hook\fP command. If unset, no such confirmation prompt will
984cd593
JB
50+ ** be presented. This is generally considered unsafe, especially where
51+ ** typos are concerned.
52+ */
53 { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
9d38a728
JB
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,
984cd593 59 OPTPGPIGNORESUB,
9d38a728
JB
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
984cd593
JB
63 size_t keylist_used = 0;
64+ LIST *hook_list = NULL;
65+ LIST *hook = NULL;
66 ADDRESS *tmp = NULL, *addr = NULL;
9d38a728 67@@ -1051,66 +1053,93 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
984cd593
JB
68 q = p;
69- k_info = NULL;
70
9d38a728 71- if ((keyID = mutt_crypt_hook (p)) != NULL)
984cd593
JB
72+ /*
73+ * grab the list of matching hooks (matching on recipient address)
74+ * process each entry singly so that auto key selection still works
75+ */
9d38a728 76+ hook_list = mutt_crypt_hook (p);
984cd593
JB
77+ hook = hook_list;
78+ while (1)
79 {
80 int r;
81- snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
82- if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
83+
84+ k_info = NULL;
9d38a728 85+ key = NULL;
984cd593
JB
86+
87+ if (hook)
88 {
9d38a728 89- if (is_numerical_keyid (keyID))
984cd593
JB
90+ keyID = (char *)hook->data;
91+ snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
9d38a728 92+ if (!option(OPTCRYPTCONFIRMHOOK) || (r = mutt_yesorno (buf, M_YES)) == M_YES)
984cd593 93 {
9d38a728
JB
94- if (strncmp (keyID, "0x", 2) == 0)
95- keyID += 2;
96- goto bypass_selection; /* you don't see this. */
97+ if (is_numerical_keyid (keyID))
98+ {
99+ if (strncmp (keyID, "0x", 2) == 0)
100+ keyID += 2;
101+ goto bypass_selection; /* you don't see this. */
102+ }
103+
984cd593
JB
104+ /* check for e-mail address */
105+ if ((t = strchr (keyID, '@')) &&
106+ (addr = rfc822_parse_adrlist (NULL, keyID)))
107+ {
108+ if (fqdn) rfc822_qualify (addr, fqdn);
109+ q = addr;
110+ }
111+ else
112+ k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
9d38a728
JB
113 }
114-
115- /* check for e-mail address */
116- if ((t = strchr (keyID, '@')) &&
117- (addr = rfc822_parse_adrlist (NULL, keyID)))
984cd593 118+ else if (r == -1)
9d38a728
JB
119 {
120- if (fqdn) rfc822_qualify (addr, fqdn);
121- q = addr;
984cd593
JB
122+ /*
123+ * yes, this implies that if one key fails they all do
124+ */
9d38a728 125+ FREE (&keylist);
984cd593
JB
126+ rfc822_free_address (&tmp);
127+ rfc822_free_address (&addr);
128+ mutt_free_list (&hook_list);
129+ return NULL;
130 }
131- else
132- k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
9d38a728 133 }
984cd593
JB
134- else if (r == -1)
135- {
9d38a728 136- FREE (&keylist);
984cd593
JB
137- rfc822_free_address (&tmp);
138- rfc822_free_address (&addr);
139- return NULL;
9d38a728 140- }
984cd593
JB
141- }
142
143- if (k_info == NULL)
144- pgp_invoke_getkeys (q);
9d38a728 145-
984cd593
JB
146- if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
147- {
148- snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
9d38a728
JB
149+ if (k_info == NULL)
150+ pgp_invoke_getkeys (q);
151
984cd593
JB
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)
155 {
9d38a728 156- FREE (&keylist);
984cd593
JB
157- rfc822_free_address (&tmp);
158- rfc822_free_address (&addr);
159- return NULL;
160+ snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
161+
162+ if ((key = pgp_ask_for_key (buf, q->mailbox,
163+ KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
164+ {
9d38a728 165+ FREE (&keylist);
984cd593
JB
166+ rfc822_free_address (&tmp);
167+ rfc822_free_address (&addr);
168+ mutt_free_list (&hook_list);
169+ return NULL;
170+ }
171 }
172- }
173- else
174- key = k_info;
175+ else
176+ key = k_info;
177
178- keyID = pgp_keyid (key);
9d38a728
JB
179+ keyID = pgp_keyid (key);
180
181 bypass_selection:
984cd593 182- keylist_size += mutt_strlen (keyID) + 4;
9d38a728 183- safe_realloc (&keylist, keylist_size);
984cd593
JB
184- sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
185- keyID);
186- keylist_used = mutt_strlen (keylist);
984cd593 187+ keylist_size += mutt_strlen (keyID) + 4;
9d38a728 188+ safe_realloc (&keylist, keylist_size);
984cd593
JB
189+ sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
190+ keyID);
191+ keylist_used = mutt_strlen (keylist);
9d38a728
JB
192
193- pgp_free_key (&key);
194- rfc822_free_address (&addr);
984cd593
JB
195+ pgp_free_key (&key);
196+ rfc822_free_address (&addr);
197+
198+ if (!hook_list)
199+ break;
200+
201+ hook = hook->next;
202+ if (!hook)
203+ break;
984cd593 204+
984cd593 205+ }
9d38a728 206+ mutt_free_list (&hook_list);
984cd593 207
9d38a728
JB
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 *);
984cd593 211 char *mutt_get_parameter (const char *, PARAMETER *);
9d38a728
JB
212-char *mutt_crypt_hook (ADDRESS *);
213+LIST *mutt_crypt_hook (ADDRESS *);
984cd593 214 char *mutt_make_date (char *, size_t);
9d38a728
JB
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.
984cd593 223
9d38a728
JB
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
232+recipient.
233 .TP
This page took 0.117339 seconds and 4 git commands to generate.