[Exim] order of headers add

Top Page
Delete this message
Reply to this message
Author: Petr Cech
Date:  
To: EXIM users list
Subject: [Exim] order of headers add
Hi,
I've been asked to look at how to simulate qmail's Delivered-To: headers.
The simplest was to add headers_add = "Delivered-to: $local_part@$domain" to
every director. This is probably not the correct think to do as these headers
will stay there when some alias expands to non-local adress, but I suspect,
that qmail does this too. But to I've encountred a problem - headers are in
oposite order. Say a have
/etc/aliases:
e:f
f:g
g:cech

and the final mail has

Delivered-to: cech@???
Delivered-to: g@???
Delivered-to: f@???
Delivered-to: e@???

which is IMHO bad. This affects the whole section of directors, because new
address is added at the start of extra_headers. I can see the reason, it's
easier to code and faster too. But since I've needed it and it was a good
exercise in understanding exim, I've done a patch to correct it.

Suggestions, comments?

                Petr Cech
-- 
Debian GNU/Linux maintainer - www.debian.{org,cz}
           cech@???


<sgore> We Are Debian. You Will Be Packaged. Media Opinion Is Irrelevant.
--- direct.c.orig    Wed Apr 12 11:44:54 2000
+++ direct.c    Mon May  8 15:20:01 2000
@@ -346,6 +346,11 @@
     {
     char *addnl = "";
     int slen = (int)strlen(s);
+#ifdef PETA
+    header_line *addr_ptr;
+#else
+#error NO PETA
+#endif
     if (slen > 0)
       {
       if (s[slen-1] != '\n')
@@ -355,10 +360,27 @@
         }
       h = store_get(sizeof(header_line));
       h->text = string_sprintf("%s%s", s, addnl);
+#ifndef PETA
       h->next = addr->extra_headers;
       h->type = htype_other;
       h->slen = slen;
       *extra_headers = h;
+#else
+      /* craft new header */
+      h->next = NULL; /* we are at the end */
+      h->type = htype_other;
+      h->slen = slen;
+      *extra_headers = addr->extra_headers; /* put the existing ones first */
+      if(*extra_headers == NULL) *extra_headers = h; /* none were there, so only put whis one */
+      else
+        {
+      /* now to find the end of extra_headers  */
+          addr_ptr = addr->extra_headers;
+          while (addr_ptr->next != NULL) addr_ptr = addr_ptr->next;
+      /* and add the header there */
+          addr_ptr->next = h;
+    }
+#endif
       }
     }
   }