summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2007-02-07 11:24:56 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2007-02-07 11:24:56 +0000
commite28326d8a5aad335b724b9ff1e5222c914e56143 (patch)
tree9483711ad70855aa747ac9681a5439fa1cb7746d
parent3a0615784b9974a727afc9d503e9647f52fc630c (diff)
Split long fakereject and fakedefer messages.
-rw-r--r--doc/doc-txt/ChangeLog6
-rw-r--r--src/src/acl.c47
-rw-r--r--src/src/functions.h3
-rw-r--r--src/src/string.c63
-rw-r--r--test/confs/055528
-rw-r--r--test/log/05552
-rw-r--r--test/scripts/0000-Basic/055520
-rw-r--r--test/stdout/055515
-rw-r--r--test/stdout/40006
9 files changed, 142 insertions, 48 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 715a57898..2e7d57a20 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -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
-------------------------------------------
@@ -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/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
-----------------
diff --git a/src/src/acl.c b/src/src/acl.c
index d0ed0a51c..78b30addc 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -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 *
@@ -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. */
-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;
}
diff --git a/src/src/functions.h b/src/src/functions.h
index f71b5aa99..55a2e22d3 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -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 *
@@ -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_split_message(uschar *);
extern BOOL string_vformat(uschar *, int, char *, va_list);
extern int strcmpic(uschar *, uschar *);
extern int strncmpic(uschar *, uschar *, int);
diff --git a/src/src/string.c b/src/src/string.c
index c0a8805fe..b52d4ab95 100644
--- a/src/src/string.c
+++ b/src/src/string.c
@@ -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 *
@@ -450,6 +450,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 *
*************************************************/
diff --git a/test/confs/0555 b/test/confs/0555
new file mode 100644
index 000000000..07b3a59ca
--- /dev/null
+++ b/test/confs/0555
@@ -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
index 000000000..e223bd466
--- /dev/null
+++ b/test/log/0555
@@ -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
index 000000000..947f1692d
--- /dev/null
+++ b/test/scripts/0000-Basic/0555
@@ -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
index 000000000..b821e7b4b
--- /dev/null
+++ b/test/stdout/0555
@@ -0,0 +1,15 @@
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+250 OK
+250 Accepted
+354 Enter message, ending with "." on a line by itself
+550-Your message has been rejected but is being kept for evaluation.
+550-If it was a legitimate message, it may still be delivered to the target
+550 recipient(s).
+221 myhost.test.ex closing connection
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+250 OK
+250 Accepted
+354 Enter message, ending with "." on a line by itself
+450-This is a rather long customised message that should get automatically
+450 split up into more than one response line.
+221 myhost.test.ex closing connection
diff --git a/test/stdout/4000 b/test/stdout/4000
index b9562b619..819f449ef 100644
--- a/test/stdout/4000
+++ b/test/stdout/4000
@@ -37,7 +37,8 @@
250 Accepted
354 Enter message, ending with "." on a line by itself
550-Your message has been rejected but is being kept for evaluation.
-550 If it was a legitimate message, it may still be delivered to the target recipient(s).
+550-If it was a legitimate message, it may still be delivered to the target
+550 recipient(s).
221 myhost.test.ex closing connection
220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
250-myhost.test.ex Hello CALLER at test.ex
@@ -58,7 +59,8 @@
250 Accepted
354 Enter message, ending with "." on a line by itself
450-Your message has been rejected but is being kept for evaluation.
-450 If it was a legitimate message, it may still be delivered to the target recipient(s).
+450-If it was a legitimate message, it may still be delivered to the target
+450 recipient(s).
221 myhost.test.ex closing connection
220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
250 OK