]> git.pld-linux.org Git - packages/mutt.git/blob - mutt-pgp_hook.patch
- CVE references for 1.5.15
[packages/mutt.git] / mutt-pgp_hook.patch
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 --- 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))
11      {
12 +#ifdef M_CRYPTHOOK
13 +      if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK | M_CRYPTHOOK))
14 +#else
15        if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK))
16 +#endif
17        {
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  }
23  
24 -char *mutt_crypt_hook (ADDRESS *adr)
25 +LIST *mutt_crypt_hook (ADDRESS *adr)
26  {
27 -  return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
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;
38 +    if (!(hook->type & M_CRYPTHOOK))
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  }
46  
47  #ifdef USE_SOCKET
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[] = {
51    */
52 +  { "pgp_confirmhook",         DT_SYN, R_NONE, UL "crypt_confirmhook", 1 },
53 +  { "crypt_confirmhook",       DT_BOOL, R_NONE, OPTCRYPTCONFIRMHOOK, 1 },
54 +  /*
55 +  ** .pp
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.
60 +  */
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,
67    OPTPGPIGNORESUB,
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;
73 +  LIST *hook = NULL;
74    ADDRESS *tmp = NULL, *addr = NULL;
75 @@ -1051,66 +1053,93 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
76      q = p;
77 -    k_info = NULL;
78  
79 -    if ((keyID = mutt_crypt_hook (p)) != NULL)
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 +     */
84 +    hook_list = mutt_crypt_hook (p);
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;
93 +      key = NULL;
94 +
95 +      if (hook)
96        {
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)
101         {
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 +
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);
121         }
122 -       
123 -       /* check for e-mail address */
124 -       if ((t = strchr (keyID, '@')) && 
125 -           (addr = rfc822_parse_adrlist (NULL, keyID)))
126 +       else if (r == -1)
127         {
128 -         if (fqdn) rfc822_qualify (addr, fqdn);
129 -         q = addr;
130 +         /*
131 +          * yes, this implies that if one key fails they all do
132 +          */
133 +         FREE (&keylist);
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);
141        }
142 -      else if (r == -1)
143 -      {
144 -       FREE (&keylist);
145 -       rfc822_free_address (&tmp);
146 -       rfc822_free_address (&addr);
147 -       return NULL;
148 -      }
149 -    }
150  
151 -    if (k_info == NULL)
152 -      pgp_invoke_getkeys (q);
153 -
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);
157 +      if (k_info == NULL)
158 +       pgp_invoke_getkeys (q);
159  
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        {
164 -       FREE (&keylist);
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 +       {
173 +         FREE (&keylist);
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);
187 +      keyID = pgp_keyid (key);
188      
189    bypass_selection:
190 -    keylist_size += mutt_strlen (keyID) + 4;
191 -    safe_realloc (&keylist, keylist_size);
192 -    sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "",        /* __SPRINTF_CHECKED__ */
193 -            keyID);
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__ */
198 +              keyID);
199 +      keylist_used = mutt_strlen (keylist);
200  
201 -    pgp_free_key (&key);
202 -    rfc822_free_address (&addr);
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;
212 +
213 +    }
214 +    mutt_free_list (&hook_list);
215  
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.
231  
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
240 +recipient.
241  .TP
This page took 0.051351 seconds and 3 git commands to generate.