On Mon, Sep 16, 2013 at 11:12:32PM +0200, Rejo wrote in <[email protected]>:
Hi,

I am using mutt to send encrypted e-mail to mailinglist with a small and
stable set of subscribers. In order to automate this I am running 1.5.16
with a slightly modified patch for 1.5.6 from [1]. This patch allows me
to define multiple crypt-hook like:

 send-hook '~C [email protected]' "set pgp_autoencrypt=yes"
 crypt-hook [email protected] 0x1DAF50E675FC50F3
 crypt-hook [email protected] 0x0994094621DBEFD4

This works very nicely. However, 1.5.16 is not the latest release. I was
not able to apply the forementioned patch with minor modifications only
to 1.5.21 as the affected code has undergone some changes between 1.5.16
and 1.5.21.

Now I am willing to give it try and update the patch to reflect the
current code-base. However, as I am not a coder and definately not C,
such an update will most likely take me quite some time.

Before I would embark on such a journey: has anyone this done
already? :)


[1] http://www.woolridge.ca/mutt/multiple-crypt-hook.html

Hi Rejo,

As I had to cancel a key signing with you at The Hague HS train station years ago, I do owe you a small favour. I have edited the patch of [1] so it hopefully applies to the current 1.5.21 mutt release*. Note, I have not tested it myself, you can be the guinea pig :-)

It seems to apply cleanly with:

patch < patch-1.5.21.dw.multiple-crypt-hook.2

from the directory with mutt 1.5.21 sources in it.

I'm interested in hearing if this works for you.

Kind regards,

Remmy

*) The original patch was also nice enough to update the documentation to document this change, I'm too lazy for that as the documentation files seem to have changed / moved / depend on some other patch.
Index: PATCHES
===================================================================
--- PATCHES
+++ PATCHES     2013-09-17 19:48:19.385345516 +0200
@@ -0,0 +1 @@
+patch-1.5.21.dw.multiple-crypt-hook.2
Index: hook.c
===================================================================
--- hook.c
+++ hook.c      2013-09-17 19:47:16.735210975 +0200
@@ -125,7 +125,11 @@
        ptr->rx.not == not &&
        !mutt_strcmp (pattern.data, ptr->rx.pattern))
     {
+#ifdef M_CRYPTHOOK
+      if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | 
M_ACCOUNTHOOK | M_REPLYHOOK | M_CRYPTHOOK))
+#else
       if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | 
M_ACCOUNTHOOK | M_REPLYHOOK))
+#endif
       {
        /* these hooks allow multiple commands with the same
         * pattern, so if we've already seen this pattern/command pair, just
@@ -451,9 +455,25 @@
   return _mutt_string_hook (chs, M_ICONVHOOK);
 }
 
-char *mutt_crypt_hook (ADDRESS *adr)
+LIST *mutt_crypt_hook (ADDRESS *adr)
 {
-  return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
+  HOOK *hook;
+  LIST *key_list = NULL;
+
+  if (!adr && !adr->mailbox)
+    return (NULL);
+
+  for (hook = Hooks; hook; hook = hook->next)
+  {
+    if (!hook->command)
+      continue;
+    if (!(hook->type & M_CRYPTHOOK))
+      continue;
+
+    if ((regexec (hook->rx.rx, adr->mailbox, 0, NULL, 0) == 0) ^ hook->rx.not)
+      key_list = mutt_add_list (key_list, hook->command);
+  }
+  return (key_list);
 }
 
 #ifdef USE_SOCKET
Index: pgp.c
===================================================================
--- pgp.c
+++ pgp.c       2013-09-17 19:47:22.882223913 +0200
@@ -1155,6 +1155,8 @@
   char *keyID, *keylist = NULL;
   size_t keylist_size = 0;
   size_t keylist_used = 0;
+  LIST *hook_list = NULL;
+  LIST *hook = NULL;
   ADDRESS *tmp = NULL, *addr = NULL;
   ADDRESS **last = &tmp;
   ADDRESS *p, *q;
Index: protos.h
===================================================================
--- protos.h
+++ protos.h    2013-09-17 19:47:22.882223913 +0200
@@ -145,7 +145,7 @@
 char *mutt_get_body_charset (char *, size_t, BODY *);
 const char *mutt_get_name (ADDRESS *);
 char *mutt_get_parameter (const char *, PARAMETER *);
-char *mutt_crypt_hook (ADDRESS *);
+LIST *mutt_crypt_hook (ADDRESS *);
 char *mutt_make_date (char *, size_t);
 
 const char *mutt_make_version (void);

Attachment: pgpSgErmvMhou.pgp
Description: PGP signature

Reply via email to