[Exim] [Updated Patch] Make domain-part of message-id config…

Pàgina inicial
Delete this message
Reply to this message
Autor: Andreas Metzler
Data:  
A: exim-users
Assumpte: [Exim] [Updated Patch] Make domain-part of message-id configurable.
--
--
Hello,
I already tried to get this into exim3 but I was to late after the
feature freeze, this version is for exim 4.10.

The attached patch adds a new global option message_id_header_domain,
which is used as domain-part in generated messages-ids and defaults to
primary_hostname. (inn uses domain in readers.conf for this purpose).

The patch is straightforward, I basically just copied the code for
message_id_header_text. An update for spec.txt is included.
            cu andreas
--
Hey, da ist ein Ballonautomat auf der Toilette!
vim:ls=2:stl=***\ Sing\ a\ song.\ ***
--
diff -Nur exim-4.10.orig/doc/spec.txt exim-4.10/doc/spec.txt
--- exim-4.10.orig/doc/spec.txt    Mon Jul 22 10:59:53 2002
+++ exim-4.10/doc/spec.txt    Sat Nov  9 14:58:48 2002
@@ -7793,6 +7793,14 @@
     This option specifies how much of a message's body is to be included in
     the $message_body and $message_body_end expansion variables.


+message_id_header_domain        Type: string*                  Default: unset
+
+    If this variable is set, the string is expanded and used as right
+    hand side (domain-part) of the Message-id: header that Exim creates if an
+    incoming message does not have one. If this is unset the primary
+    hostname will be used. Only the characters A-Z, a-z, 0-9, . and - are
+    accepted, all others are replaced by hyphens.
+
 message_id_header_text          Type: string*                  Default: unset


     If this variable is set, the string is expanded and used to augment the
@@ -17142,9 +17150,10 @@
 header line, Exim adds one to the message. If there are any Resent-: headers
 in the message, it creates Resent-Message-id:. The id is constructed from
 Exim's internal message id, preceded by the letter E to ensure it starts with
-a letter, and followed by @ and the primary host name. Additional information
-can be included in this header line by setting the "message_id_header_text"
-option.
+a letter, and followed by @ and the primary host name. If
+"message_id_header_domain" is set its value is used instead of the primary
+host name. Additional information can be included in this header line by
+setting the "message_id_header_text" option.



 43.10 The Received: header line
diff -Nur exim-4.10.orig/src/globals.c exim-4.10/src/globals.c
--- exim-4.10.orig/src/globals.c    Mon Jul 22 10:59:48 2002
+++ exim-4.10/src/globals.c    Sat Nov  9 14:52:38 2002
@@ -521,6 +521,7 @@
 uschar *message_headers        = NULL;
 uschar *message_id;
 uschar *message_id_text        = NULL;
+uschar *message_id_domain      = NULL;
 uschar  message_id_option[MESSAGE_ID_LENGTH + 3];
 uschar *message_id_external;
 int     message_linecount      = 0;
diff -Nur exim-4.10.orig/src/globals.h exim-4.10/src/globals.h
--- exim-4.10.orig/src/globals.h    Mon Jul 22 10:59:49 2002
+++ exim-4.10/src/globals.h    Sat Nov  9 14:52:38 2002
@@ -314,6 +314,7 @@
 extern uschar *message_id_external;    /* External form of following */
 extern uschar *message_id;             /* Internal id of message being handled */
 extern uschar *message_id_text;        /* Expanded to form message_id */
+extern uschar *message_id_domain;      /* Expanded to form domain-part of message_id */
 extern int     message_linecount;      /* As it says */
 extern BOOL    message_logs;           /* TRUE to write message logs */
 extern int     message_size;           /* Size of message */
diff -Nur exim-4.10.orig/src/readconf.c exim-4.10/src/readconf.c
--- exim-4.10.orig/src/readconf.c    Mon Jul 22 10:59:50 2002
+++ exim-4.10/src/readconf.c    Sat Nov  9 14:52:38 2002
@@ -110,6 +110,7 @@
   { "lookup_open_max",          opt_int,         &lookup_open_max },
   { "max_username_length",      opt_int,         &max_username_length },
   { "message_body_visible",     opt_mkint,       &message_body_visible },
+  { "message_id_header_domain",   opt_stringptr,   &message_id_domain },
   { "message_id_header_text",   opt_stringptr,   &message_id_text },
   { "message_logs",             opt_bool,        &message_logs },
   { "message_size_limit",       opt_stringptr,   &message_size_limit },
diff -Nur exim-4.10.orig/src/receive.c exim-4.10/src/receive.c
--- exim-4.10.orig/src/receive.c    Mon Jul 22 10:59:50 2002
+++ exim-4.10/src/receive.c    Sat Nov  9 14:52:38 2002
@@ -1786,6 +1786,31 @@
 if (msgid_header == NULL)
   {
   BOOL use_default = TRUE;
+  /* use primary_hostname or message_id_domain for domain-part
+   * of Message-ID */
+  char *my_message_id_domain;
+  if (message_id_domain != NULL)
+    {
+    my_message_id_domain = expand_string(message_id_domain);
+    if ((my_message_id_domain != 0) && (*my_message_id_domain != 0))
+      {
+      uschar *ee;
+      for (ee = (uschar *)my_message_id_domain; *ee != 0; ee++)
+         /* Accept only a-z A-Z - and .
+          * 45 is -, 122 is z */
+        if ((*ee) < 45 || (*ee) > 122 || strchr("/<>;:?=@[]\\^_`", (*ee)) != NULL) *ee = '-';
+      }
+    else
+      {
+      log_write(0, LOG_MAIN|LOG_PANIC,
+        "expansion of \"%s\" (message_id_header_domain) "
+        "failed: %s", message_id_domain, expand_string_message);
+      my_message_id_domain=primary_hostname;
+      }
+    }
+  else
+    my_message_id_domain=primary_hostname;
+
   if (message_id_text != NULL)
     {
     uschar *e = expand_string(message_id_text);
@@ -1797,7 +1822,7 @@
         for (ee = (uschar *)e; *ee != 0; ee++)
           if (mac_iscntrl_or_special(*ee)) *ee = '-';
         header_add(htype_id, "%sMessage-Id: <%s.%s@%s>\n", resent_prefix,
-          message_id_external, e, primary_hostname);
+          message_id_external, e, my_message_id_domain);
         use_default = FALSE;
         }
       }
@@ -1808,7 +1833,7 @@
     }
   if (use_default)
     header_add(htype_id, "%sMessage-Id: <%s@%s>\n", resent_prefix,
-      message_id_external, primary_hostname);
+      message_id_external, my_message_id_domain);
   }


/* Ensure the recipients list is fully qualified and rewritten. If we
--
[ Content of type application/pgp-signature deleted ]
--