[exim-dev] submission mode enhancements

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Tony Finch
Fecha:  
A: exim-dev
Asunto: [exim-dev] submission mode enhancements
The attached patch fixes a couple of bugs and adds a feature to submission
mode.

There's a bug in the handling of the /domain= option which may cause
memory corruption. There's a similar bug in the fakereject option, though
that isn't directly relevant to this post.

Although submission mode can fix up the Sender: header it doesn't fix the
return path. This patch causes it to do so.

The bare email address in the Sender: header is slightly ugly. I've added
a /name= option so that you can make the user's friendly name appear in
the header.

Tony.
--
<fanf@???> <dot@???> http://dotat.at/ ${sg{\N${sg{\
N\}{([^N]*)(.)(.)(.*)}{\$1\$3\$2\$1\$3\n\$2\$3\$4\$3\n\$3\$2\$4}}\
\N}{([^N]*)(.)(.)(.*)}{\$1\$3\$2\$1\$3\n\$2\$3\$4\$3\n\$3\$2\$4}}--- src/acl.c    11 May 2005 09:26:55 -0000    1.30
+++ src/acl.c    13 May 2005 16:49:42 -0000
@@ -2107,7 +2107,7 @@
         {
         uschar *pp = p + 1;
         while (*pp != 0) pp++;
-        fake_reject_text = expand_string(string_copyn(p+1, pp-p));
+        fake_reject_text = expand_string(string_copyn(p+1, pp-p-1));
         p = pp;
         }
        else
@@ -2128,6 +2128,7 @@
 
       case CONTROL_SUBMISSION:
       submission_mode = TRUE;
+      originator_name = "";
       while (*p == '/')
         {
         if (Ustrncmp(p, "/sender_retain", 14) == 0)
@@ -2140,7 +2141,15 @@
           {
           uschar *pp = p + 8;
           while (*pp != 0 && *pp != '/') pp++;
-          submission_domain = string_copyn(p+8, pp-p);
+          submission_domain = string_copyn(p+8, pp-p-8);
+          p = pp;
+          }
+        else if (Ustrncmp(p, "/name=", 6) == 0)
+          {
+          uschar *pp = p + 6;
+          while (*pp != 0 && *pp != '/') pp++;
+          originator_name = string_copy(parse_fix_phrase(p+6, pp-p-6,
+            big_buffer, big_buffer_size));
           p = pp;
           }
         else break;
--- src/receive.c    27 Apr 2005 13:29:32 -0000    1.16
+++ src/receive.c    13 May 2005 16:49:42 -0000
@@ -2341,34 +2341,22 @@
 
   if (sender_address[0] == 0)
     {
-    if (sender_local || local_error_message)
-      {
-      header_add(htype_from, "%sFrom: %s%s%s@%s%s\n", resent_prefix,
-        originator_name,
-        (originator_name[0] == 0)? "" : " <",
-        local_part_quote(originator_login),
-        qualify_domain_sender,
-        (originator_name[0] == 0)? "" : ">");
-      }
-    else if (submission_mode && authenticated_id != NULL)
-      {
-      if (submission_domain == NULL)
-        {
-        header_add(htype_from, "%sFrom: %s@%s\n", resent_prefix,
-          local_part_quote(authenticated_id), qualify_domain_sender);
-        }
-      else if (submission_domain[0] == 0)  /* empty => whole address set */
-        {
-        header_add(htype_from, "%sFrom: %s\n", resent_prefix,
-          authenticated_id);
-        }
-      else
-        {
-        header_add(htype_from, "%sFrom: %s@%s\n", resent_prefix,
-          local_part_quote(authenticated_id), submission_domain);
-        }
+    header_add(htype_from, "%sFrom: %s%s%s%s%s%s\n", resent_prefix,
+      originator_name,
+      (originator_name[0] == 0)? "" : " <",
+
+      (submission_mode && authenticated_id != NULL)?
+      local_part_quote(authenticated_id) :
+      local_part_quote(originator_login),
+
+      (submission_domain != NULL && submission_domain[0] == 0)? "" : "@",
+
+      (submission_domain == NULL)? qualify_domain_sender :
+      (submission_domain[0] != 0)? submission_domain : US"",
+
+      (originator_name[0] == 0)? "" : ">");
+
       from_header = header_last;    /* To get it checked for Sender: */
-      }
     }
 
   /* There is a non-null envelope sender. Build the header using the original
@@ -2377,15 +2365,12 @@
 
   else
     {
-    if (!smtp_input || sender_local)
-      header_add(htype_from, "%sFrom: %s%s%s%s\n",
-        resent_prefix, originator_name,
-        (originator_name[0] == 0)? "" : " <",
-        (sender_address_unrewritten == NULL)?
-          sender_address : sender_address_unrewritten,
-        (originator_name[0] == 0)? "" : ">");
-    else
-      header_add(htype_from, "%sFrom: %s\n", resent_prefix, sender_address);
+    header_add(htype_from, "%sFrom: %s%s%s%s\n", resent_prefix,
+      originator_name,
+      (originator_name[0] == 0)? "" : " <",
+      (sender_address_unrewritten == NULL)?
+        sender_address : sender_address_unrewritten,
+      (originator_name[0] == 0)? "" : ">");
 
     from_header = header_last;    /* To get it checked for Sender: */
     }
@@ -2466,12 +2451,25 @@
 
   if (make_sender)
     {
-    if (submission_mode)
+    if (submission_mode && originator_name[0] == 0)
       header_add(htype_sender, "%sSender: %s\n", resent_prefix,
         generated_sender_address);
     else
       header_add(htype_sender, "%sSender: %s <%s>\n",
         resent_prefix, originator_name, generated_sender_address);
+    }
+
+  /* Ensure that a non-null envelope sender address corresponds to the
+  submission mode sender address. */
+
+  if (submission_mode && sender_address[0] != 0)
+    {
+    if (sender_address_unrewritten == NULL)
+      sender_address_unrewritten = sender_address;
+    sender_address = generated_sender_address;
+    log_write(L_address_rewrite, LOG_MAIN,
+      "\"%s\" from env-from rewritten as \"%s\" by submission mode",
+      sender_address_unrewritten, generated_sender_address);
     }
   }