]> git.pld-linux.org Git - packages/mutt.git/blob - 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
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
9      {
10 +#ifdef M_CRYPTHOOK
11 +      if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK | M_CRYPTHOOK))
12 +#else
13        if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK))
14 +#endif
15        {
16 @@ -445,5 +449,21 @@ char *mutt_iconv_hook (const char *chs)
17  
18 -char *mutt_crypt_hook (ADDRESS *adr)
19 +LIST *mutt_crypt_hook (ADDRESS *adr)
20  {
21 -  return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
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;
32 +    if (!(hook->type & M_CRYPTHOOK))
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  }
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[] = {
43    */
44 +  { "pgp_confirmhook",         DT_SYN, R_NONE, UL "crypt_confirmhook", 1 },
45 +  { "crypt_confirmhook",       DT_BOOL, R_NONE, OPTCRYPTCONFIRMHOOK, 1 },
46 +  /*
47 +  ** .pp
48 +  ** If set, then you will be prompted for confirmation of keys when using
49 +  ** the \fIcrypt-hook\fP command.  If unset, no such confirmation prompt will
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},
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,
59    OPTPGPIGNORESUB,
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
63    size_t keylist_used = 0;
64 +  LIST *hook_list = NULL;
65 +  LIST *hook = NULL;
66    ADDRESS *tmp = NULL, *addr = NULL;
67 @@ -1051,66 +1053,93 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS
68      q = p;
69 -    k_info = NULL;
70  
71 -    if ((keyID = mutt_crypt_hook (p)) != NULL)
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 +     */
76 +    hook_list = mutt_crypt_hook (p);
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;
85 +      key = NULL;
86 +
87 +      if (hook)
88        {
89 -       if (is_numerical_keyid (keyID))
90 +       keyID = (char *)hook->data;
91 +       snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
92 +       if (!option(OPTCRYPTCONFIRMHOOK) || (r = mutt_yesorno (buf, M_YES)) == M_YES)
93         {
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 +
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);
113         }
114 -       
115 -       /* check for e-mail address */
116 -       if ((t = strchr (keyID, '@')) && 
117 -           (addr = rfc822_parse_adrlist (NULL, keyID)))
118 +       else if (r == -1)
119         {
120 -         if (fqdn) rfc822_qualify (addr, fqdn);
121 -         q = addr;
122 +         /*
123 +          * yes, this implies that if one key fails they all do
124 +          */
125 +         FREE (&keylist);
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);
133        }
134 -      else if (r == -1)
135 -      {
136 -       FREE (&keylist);
137 -       rfc822_free_address (&tmp);
138 -       rfc822_free_address (&addr);
139 -       return NULL;
140 -      }
141 -    }
142  
143 -    if (k_info == NULL)
144 -      pgp_invoke_getkeys (q);
145 -
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);
149 +      if (k_info == NULL)
150 +       pgp_invoke_getkeys (q);
151  
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        {
156 -       FREE (&keylist);
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 +       {
165 +         FREE (&keylist);
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);
179 +      keyID = pgp_keyid (key);
180      
181    bypass_selection:
182 -    keylist_size += mutt_strlen (keyID) + 4;
183 -    safe_realloc (&keylist, keylist_size);
184 -    sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "",        /* __SPRINTF_CHECKED__ */
185 -            keyID);
186 -    keylist_used = mutt_strlen (keylist);
187 +      keylist_size += mutt_strlen (keyID) + 4;
188 +      safe_realloc (&keylist, keylist_size);
189 +      sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "",      /* __SPRINTF_CHECKED__ */
190 +              keyID);
191 +      keylist_used = mutt_strlen (keylist);
192  
193 -    pgp_free_key (&key);
194 -    rfc822_free_address (&addr);
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;
204 +
205 +    }
206 +    mutt_free_list (&hook_list);
207  
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 *);
211  char *mutt_get_parameter (const char *, PARAMETER *);
212 -char *mutt_crypt_hook (ADDRESS *);
213 +LIST *mutt_crypt_hook (ADDRESS *);
214  char *mutt_make_date (char *, size_t);
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.
223  
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.107371 seconds and 4 git commands to generate.