]> git.pld-linux.org Git - packages/mutt.git/blame - mutt-pgp_hook.patch
- updated to 1.5.19 (partially done)
[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
c33d9068
JB
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
9 ptr->rx.not == not &&
10 !mutt_strcmp (pattern.data, ptr->rx.pattern))
984cd593 11 {
9d38a728 12+#ifdef M_CRYPTHOOK
c33d9068 13+ if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK | M_CRYPTHOOK))
984cd593 14+#else
c33d9068 15 if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK))
9d38a728 16+#endif
984cd593 17 {
c33d9068
JB
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);
22 }
984cd593 23
9d38a728
JB
24-char *mutt_crypt_hook (ADDRESS *adr)
25+LIST *mutt_crypt_hook (ADDRESS *adr)
984cd593 26 {
9d38a728 27- return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
984cd593
JB
28+ HOOK *hook;
29+ LIST *key_list = NULL;
30+
31+ if (!adr && !adr->mailbox)
32+ return (NULL);
33+
34+ for (hook = Hooks; hook; hook = hook->next)
35+ {
36+ if (!hook->command)
37+ continue;
9d38a728 38+ if (!(hook->type & M_CRYPTHOOK))
984cd593
JB
39+ continue;
40+
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);
43+ }
44+ return (key_list);
45 }
c33d9068
JB
46
47 #ifdef USE_SOCKET
9d38a728
JB
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[] = {
984cd593 51 */
9d38a728
JB
52+ { "pgp_confirmhook", DT_SYN, R_NONE, UL "crypt_confirmhook", 1 },
53+ { "crypt_confirmhook", DT_BOOL, R_NONE, OPTCRYPTCONFIRMHOOK, 1 },
984cd593
JB
54+ /*
55+ ** .pp
56+ ** If set, then you will be prompted for confirmation of keys when using
9d38a728 57+ ** the \fIcrypt-hook\fP command. If unset, no such confirmation prompt will
984cd593
JB
58+ ** be presented. This is generally considered unsafe, especially where
59+ ** typos are concerned.
60+ */
61 { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
9d38a728
JB
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,
984cd593 67 OPTPGPIGNORESUB,
9d38a728
JB
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
984cd593
JB
71 size_t keylist_used = 0;
72+ LIST *hook_list = NULL;
73+ LIST *hook = NULL;
74 ADDRESS *tmp = NULL, *addr = NULL;
9d38a728 75@@ -1051,66 +1053,93 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
984cd593
JB
76 q = p;
77- k_info = NULL;
78
9d38a728 79- if ((keyID = mutt_crypt_hook (p)) != NULL)
984cd593
JB
80+ /*
81+ * grab the list of matching hooks (matching on recipient address)
82+ * process each entry singly so that auto key selection still works
83+ */
9d38a728 84+ hook_list = mutt_crypt_hook (p);
984cd593
JB
85+ hook = hook_list;
86+ while (1)
87 {
88 int r;
89- snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
90- if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
91+
92+ k_info = NULL;
9d38a728 93+ key = NULL;
984cd593
JB
94+
95+ if (hook)
96 {
9d38a728 97- if (is_numerical_keyid (keyID))
984cd593
JB
98+ keyID = (char *)hook->data;
99+ snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
9d38a728 100+ if (!option(OPTCRYPTCONFIRMHOOK) || (r = mutt_yesorno (buf, M_YES)) == M_YES)
984cd593 101 {
9d38a728
JB
102- if (strncmp (keyID, "0x", 2) == 0)
103- keyID += 2;
104- goto bypass_selection; /* you don't see this. */
105+ if (is_numerical_keyid (keyID))
106+ {
107+ if (strncmp (keyID, "0x", 2) == 0)
108+ keyID += 2;
109+ goto bypass_selection; /* you don't see this. */
110+ }
111+
984cd593
JB
112+ /* check for e-mail address */
113+ if ((t = strchr (keyID, '@')) &&
114+ (addr = rfc822_parse_adrlist (NULL, keyID)))
115+ {
116+ if (fqdn) rfc822_qualify (addr, fqdn);
117+ q = addr;
118+ }
119+ else
120+ k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
9d38a728
JB
121 }
122-
123- /* check for e-mail address */
124- if ((t = strchr (keyID, '@')) &&
125- (addr = rfc822_parse_adrlist (NULL, keyID)))
984cd593 126+ else if (r == -1)
9d38a728
JB
127 {
128- if (fqdn) rfc822_qualify (addr, fqdn);
129- q = addr;
984cd593
JB
130+ /*
131+ * yes, this implies that if one key fails they all do
132+ */
9d38a728 133+ FREE (&keylist);
984cd593
JB
134+ rfc822_free_address (&tmp);
135+ rfc822_free_address (&addr);
136+ mutt_free_list (&hook_list);
137+ return NULL;
138 }
139- else
140- k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
9d38a728 141 }
984cd593
JB
142- else if (r == -1)
143- {
9d38a728 144- FREE (&keylist);
984cd593
JB
145- rfc822_free_address (&tmp);
146- rfc822_free_address (&addr);
147- return NULL;
9d38a728 148- }
984cd593
JB
149- }
150
151- if (k_info == NULL)
152- pgp_invoke_getkeys (q);
9d38a728 153-
984cd593
JB
154- if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
155- {
156- snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
9d38a728
JB
157+ if (k_info == NULL)
158+ pgp_invoke_getkeys (q);
159
984cd593
JB
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)
163 {
9d38a728 164- FREE (&keylist);
984cd593
JB
165- rfc822_free_address (&tmp);
166- rfc822_free_address (&addr);
167- return NULL;
168+ snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
169+
170+ if ((key = pgp_ask_for_key (buf, q->mailbox,
171+ KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
172+ {
9d38a728 173+ FREE (&keylist);
984cd593
JB
174+ rfc822_free_address (&tmp);
175+ rfc822_free_address (&addr);
176+ mutt_free_list (&hook_list);
177+ return NULL;
178+ }
179 }
180- }
181- else
182- key = k_info;
183+ else
184+ key = k_info;
185
186- keyID = pgp_keyid (key);
9d38a728
JB
187+ keyID = pgp_keyid (key);
188
189 bypass_selection:
984cd593 190- keylist_size += mutt_strlen (keyID) + 4;
9d38a728 191- safe_realloc (&keylist, keylist_size);
984cd593
JB
192- sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
193- keyID);
194- keylist_used = mutt_strlen (keylist);
984cd593 195+ keylist_size += mutt_strlen (keyID) + 4;
9d38a728 196+ safe_realloc (&keylist, keylist_size);
984cd593
JB
197+ sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
198+ keyID);
199+ keylist_used = mutt_strlen (keylist);
9d38a728
JB
200
201- pgp_free_key (&key);
202- rfc822_free_address (&addr);
984cd593
JB
203+ pgp_free_key (&key);
204+ rfc822_free_address (&addr);
205+
206+ if (!hook_list)
207+ break;
208+
209+ hook = hook->next;
210+ if (!hook)
211+ break;
984cd593 212+
984cd593 213+ }
9d38a728 214+ mutt_free_list (&hook_list);
984cd593 215
9d38a728
JB
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 *);
984cd593 219 char *mutt_get_parameter (const char *, PARAMETER *);
9d38a728
JB
220-char *mutt_crypt_hook (ADDRESS *);
221+LIST *mutt_crypt_hook (ADDRESS *);
984cd593 222 char *mutt_make_date (char *, size_t);
c33d9068
JB
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
bebcbf73
AG
225@@ -3293,7 +3293,9 @@
226 or because, for some reasons, you need to override the key Mutt would
227 normally use. The <literal>crypt-hook</literal> command provides a
228 method by which you can specify the ID of the public key to be used
229-when encrypting messages to a certain recipient.
230+when encrypting messages to a certain recipient. You may use multiple pgp-hook's
231+with the same pattern; multiple matching pgp-hook's result in the use of multiple
9d38a728 232+keyids for recipient.
bebcbf73 233 </para>
984cd593 234
bebcbf73 235 <para>
9d38a728
JB
236--- crypt-hook-both/doc/muttrc.man.head Feb 2004 17:10:43 -0000 3.10
237+++ crypt-hook-both/doc/muttrc.man.head Feb 2004 13:19:44 -0000
238@@ -297,3 +297,6 @@ to a certain recipient. The meaning of
239 broadly: This can be a different e-mail address, a numerical key ID,
240-or even just an arbitrary search string.
241+or even just an arbitrary search string. You may use multiple
242+\fBpgp-hook\fPs with the same \fIpattern\fP; multiple matching
243+\fBpgp-hook\fPs result in the use of multiple \fIkey-id\fPs for
244+recipient.
245 .TP
This page took 0.0964 seconds and 4 git commands to generate.