Split long fakereject and fakedefer messages.
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Wed, 7 Feb 2007 11:24:56 +0000 (11:24 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Wed, 7 Feb 2007 11:24:56 +0000 (11:24 +0000)
doc/doc-txt/ChangeLog
src/src/acl.c
src/src/functions.h
src/src/string.c
test/confs/0555 [new file with mode: 0644]
test/log/0555 [new file with mode: 0644]
test/scripts/0000-Basic/0555 [new file with mode: 0644]
test/stdout/0555 [new file with mode: 0644]
test/stdout/4000

index 715a5789839e772caade12dd153c4165e12cda5e..2e7d57a203f83cf48eb0812470be9ceffd81d88d 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.473 2007/02/06 14:49:13 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.474 2007/02/07 11:24:56 ph10 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -87,6 +87,10 @@ PH/19 Change 4.64/PH/36 introduced a bug: when address_retry_include_sender
 
 PH/20 Added hosts_avoid_pipelining to the smtp transport.
 
 
 PH/20 Added hosts_avoid_pipelining to the smtp transport.
 
+PH/21 Long custom messages for fakedefer and fakereject are now split up
+      into multiline reponses in the same way that messages for "deny" and
+      other ACL rejections are.
+
 
 Exim version 4.66
 -----------------
 
 Exim version 4.66
 -----------------
index d0ed0a51c1089a3aee55d3c120fb57840dc47685..78b30addc04c8c060747eec9dbca8bb2daa27163 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/acl.c,v 1.72 2007/02/06 12:19:27 ph10 Exp $ */
+/* $Cambridge: exim/src/src/acl.c,v 1.73 2007/02/07 11:24:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -3647,48 +3647,9 @@ if (rc == FAIL_DROP && where == ACL_WHERE_MAILAUTH)
 /* Before giving a response, take a look at the length of any user message, and
 split it up into multiple lines if possible. */
 
 /* Before giving a response, take a look at the length of any user message, and
 split it up into multiple lines if possible. */
 
-if (*user_msgptr != NULL && Ustrlen(*user_msgptr) > 75)
-  {
-  uschar *s = *user_msgptr = string_copy(*user_msgptr);
-  uschar *ss = s;
-
-  for (;;)
-    {
-    int i = 0;
-    while (i < 75 && *ss != 0 && *ss != '\n') ss++, i++;
-    if (*ss == 0) break;
-    if (*ss == '\n')
-      s = ++ss;
-    else
-      {
-      uschar *t = ss + 1;
-      uschar *tt = NULL;
-      while (--t > s + 35)
-        {
-        if (*t == ' ')
-          {
-          if (t[-1] == ':') { tt = t; break; }
-          if (tt == NULL) tt = t;
-          }
-        }
-
-      if (tt == NULL)          /* Can't split behind - try ahead */
-        {
-        t = ss + 1;
-        while (*t != 0)
-          {
-          if (*t == ' ' || *t == '\n')
-            { tt = t; break; }
-          t++;
-          }
-        }
-
-      if (tt == NULL) break;   /* Can't find anywhere to split */
-      *tt = '\n';
-      s = ss = tt+1;
-      }
-    }
-  }
+*user_msgptr = string_split_message(*user_msgptr);
+if (fake_response != OK)
+  fake_response_text = string_split_message(fake_response_text);
 
 return rc;
 }
 
 return rc;
 }
index f71b5aa992e54fc9a4348e5b5115e3203df81e83..55a2e22d329e2a22ea019ca44074d9a9e9b155b0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/functions.h,v 1.35 2007/02/06 11:11:40 ph10 Exp $ */
+/* $Cambridge: exim/src/src/functions.h,v 1.36 2007/02/07 11:24:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -310,6 +310,7 @@ extern uschar *string_log_address(address_item *, BOOL, BOOL);
 extern uschar *string_nextinlist(uschar **, int *, uschar *, int);
 extern uschar *string_open_failed(int, char *, ...);
 extern uschar *string_printing2(uschar *, BOOL);
 extern uschar *string_nextinlist(uschar **, int *, uschar *, int);
 extern uschar *string_open_failed(int, char *, ...);
 extern uschar *string_printing2(uschar *, BOOL);
+extern uschar *string_split_message(uschar *);
 extern BOOL    string_vformat(uschar *, int, char *, va_list);
 extern int     strcmpic(uschar *, uschar *);
 extern int     strncmpic(uschar *, uschar *, int);
 extern BOOL    string_vformat(uschar *, int, char *, va_list);
 extern int     strcmpic(uschar *, uschar *);
 extern int     strncmpic(uschar *, uschar *, int);
index c0a8805feafb3454a480abb077eb19792c2821c3..b52d4ab9501f94d51432b4fadf72840007e21327 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/string.c,v 1.11 2007/01/08 10:50:18 ph10 Exp $ */
+/* $Cambridge: exim/src/src/string.c,v 1.12 2007/02/07 11:24:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -449,6 +449,67 @@ return ss;
 
 
 
 
 
 
+/*************************************************
+*    Copy string if long, inserting newlines     *
+*************************************************/
+
+/* If the given string is longer than 75 characters, it is copied, and within
+the copy, certain space characters are converted into newlines.
+
+Argument:  pointer to the string
+Returns:   pointer to the possibly altered string
+*/
+
+uschar *
+string_split_message(uschar *msg)
+{
+uschar *s, *ss;
+
+if (msg == NULL || Ustrlen(msg) <= 75) return msg;
+s = ss = msg = string_copy(msg);
+
+for (;;)
+  {
+  int i = 0;
+  while (i < 75 && *ss != 0 && *ss != '\n') ss++, i++;
+  if (*ss == 0) break;
+  if (*ss == '\n')
+    s = ++ss;
+  else
+    {
+    uschar *t = ss + 1;
+    uschar *tt = NULL;
+    while (--t > s + 35)
+      {
+      if (*t == ' ')
+        {
+        if (t[-1] == ':') { tt = t; break; }
+        if (tt == NULL) tt = t;
+        }
+      }
+
+    if (tt == NULL)          /* Can't split behind - try ahead */
+      {
+      t = ss + 1;
+      while (*t != 0)
+        {
+        if (*t == ' ' || *t == '\n')
+          { tt = t; break; }
+        t++;
+        }
+      }
+
+    if (tt == NULL) break;   /* Can't find anywhere to split */
+    *tt = '\n';
+    s = ss = tt+1;
+    }
+  }
+
+return msg;
+}
+
+
+
 /*************************************************
 *   Copy returned DNS domain name, de-escaping   *
 *************************************************/
 /*************************************************
 *   Copy returned DNS domain name, de-escaping   *
 *************************************************/
diff --git a/test/confs/0555 b/test/confs/0555
new file mode 100644 (file)
index 0000000..07b3a59
--- /dev/null
@@ -0,0 +1,28 @@
+# Exim test configuration 0555
+
+FAKE=fakereject
+
+exim_path = EXIM_PATH
+host_lookup_order = bydns
+primary_hostname = myhost.test.ex
+rfc1413_query_timeout = 0s
+spool_directory = DIR/spool
+log_file_path = DIR/spool/log/%slog
+gecos_pattern = ""
+gecos_name = CALLER_NAME
+
+# ----- Main settings -----
+
+acl_smtp_rcpt = check_rcpt
+queue_only
+
+
+# ----- ACLs -----
+
+begin acl
+
+check_rcpt:
+  accept  control = FAKE
+
+
+# End
diff --git a/test/log/0555 b/test/log/0555
new file mode 100644 (file)
index 0000000..e223bd4
--- /dev/null
@@ -0,0 +1,2 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss
diff --git a/test/scripts/0000-Basic/0555 b/test/scripts/0000-Basic/0555
new file mode 100644 (file)
index 0000000..947f169
--- /dev/null
@@ -0,0 +1,20 @@
+# Long lines for fakedefer/fakereject
+exim -bs
+mail from:<>
+rcpt to:<userx@test.ex>
+data
+Message 1
+.
+quit
+****
+exim -bs -DFAKE='fakedefer/This is a rather long customised message that \
+                 should get automatically split up into more than one \
+                 response line.' 
+mail from:<>
+rcpt to:<userx@test.ex>
+data
+Message 2
+.
+quit
+****
+no_msglog_check
diff --git a/test/stdout/0555 b/test/stdout/0555
new file mode 100644 (file)
index 0000000..b821e7b
--- /dev/null
@@ -0,0 +1,15 @@
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250 OK\r
+250 Accepted\r
+354 Enter message, ending with "." on a line by itself\r
+550-Your message has been rejected but is being kept for evaluation.\r
+550-If it was a legitimate message, it may still be delivered to the target\r
+550 recipient(s).\r
+221 myhost.test.ex closing connection\r
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250 OK\r
+250 Accepted\r
+354 Enter message, ending with "." on a line by itself\r
+450-This is a rather long customised message that should get automatically\r
+450 split up into more than one response line.\r
+221 myhost.test.ex closing connection\r
index b9562b6194402357303c73e4674197e5dc03b51e..819f449ef43893c4c93c9c2d7856623a1a98682c 100644 (file)
@@ -37,7 +37,8 @@
 250 Accepted\r
 354 Enter message, ending with "." on a line by itself\r
 550-Your message has been rejected but is being kept for evaluation.\r
 250 Accepted\r
 354 Enter message, ending with "." on a line by itself\r
 550-Your message has been rejected but is being kept for evaluation.\r
-550 If it was a legitimate message, it may still be delivered to the target recipient(s).\r
+550-If it was a legitimate message, it may still be delivered to the target\r
+550 recipient(s).\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250-myhost.test.ex Hello CALLER at test.ex\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250-myhost.test.ex Hello CALLER at test.ex\r
@@ -58,7 +59,8 @@
 250 Accepted\r
 354 Enter message, ending with "." on a line by itself\r
 450-Your message has been rejected but is being kept for evaluation.\r
 250 Accepted\r
 354 Enter message, ending with "." on a line by itself\r
 450-Your message has been rejected but is being kept for evaluation.\r
-450 If it was a legitimate message, it may still be delivered to the target recipient(s).\r
+450-If it was a legitimate message, it may still be delivered to the target\r
+450 recipient(s).\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250 OK\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250 OK\r