summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2017-01-03 20:15:39 +0000
committerJeremy Harris <jgh146exb@wizmail.org>2017-01-03 21:05:02 +0000
commitf4630439f888df191a151ac935eacf04517fb2ee (patch)
treef058f8adeb582994bb79b13420926fbb7ee1553a
parent5d03669979a0faed6caec3d32f7caac9321eb160 (diff)
CHUNKING: fix non-pipelined synch checks. Bug 2004
-rw-r--r--doc/doc-txt/ChangeLog5
-rw-r--r--src/src/smtp_in.c214
-rw-r--r--test/confs/05771
-rw-r--r--test/confs/0577./aaa (renamed from test/confs/0903./aaa)0
-rw-r--r--test/confs/0577./bbb (renamed from test/confs/0903./bbb)0
-rw-r--r--[l---------]test/confs/0901122
-rw-r--r--test/confs/09031
l---------test/confs/0904 (renamed from test/confs/0902)0
l---------test/confs/09051
-rw-r--r--test/log/090151
-rw-r--r--test/log/090438
-rw-r--r--test/log/0905 (renamed from test/log/0902)0
-rw-r--r--test/rejectlog/09018
-rw-r--r--test/scripts/0000-Basic/0577 (renamed from test/scripts/0000-Basic/0903)0
-rw-r--r--test/scripts/0000-Basic/0901569
-rw-r--r--test/scripts/0000-Basic/0904387
-rw-r--r--test/scripts/0000-Basic/0905 (renamed from test/scripts/0000-Basic/0902)0
-rw-r--r--test/stdout/0901465
-rw-r--r--test/stdout/0904199
-rw-r--r--test/stdout/0905 (renamed from test/stdout/0902)0
20 files changed, 1361 insertions, 700 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 8ef8b0b6c..0222d48e4 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -19,6 +19,11 @@ PP/01 GitHub PR 50: Do not call ldap_start_tls_s on ldapi:// connections.
JH/03 Bug 2003: fix Proxy Protocol v2 handling: the address size field was
missing a wire-to-host endian conversion.
+JH/04 Bug 2004: fix CHUNKING in non-PIPELINEING mode. Chunk data following
+ close after a BDAT command line could be taken as a following command,
+ giving a synch failure. Fix by only checking for synch immediately
+ before acknowledging the chunk.
+
Exim version 4.88
-----------------
diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c
index 0935d212b..e8692ce56 100644
--- a/src/src/smtp_in.c
+++ b/src/src/smtp_in.c
@@ -82,19 +82,23 @@ enum {
MAIL_CMD, RCPT_CMD, RSET_CMD,
+ /* This is a dummy to identify the non-sync commands when not pipelining */
+
+ NON_SYNC_CMD_NON_PIPELINING,
+
/* RFC3030 section 2: "After all MAIL and RCPT responses are collected and
processed the message is sent using a series of BDAT commands"
implies that BDAT should be synchronized. However, we see Google, at least,
sending MAIL,RCPT,BDAT-LAST in a single packet, clearly not waiting for
- processing of the RPCT response(s). We shall do the same, and not require
- synch for BDAT. */
+ processing of the RCPT response(s). We shall do the same, and not require
+ synch for BDAT. Worse, as the chunk may (very likely will) follow the
+ command-header in the same packet we cannot do the usual "is there any
+ follow-on data after the commmand line" even for non-pipeline mode.
+ So we'll need an explicit check after reading the expected chunk amount
+ when non-pipe, before sennding the ACK. */
BDAT_CMD,
- /* This is a dummy to identify the non-sync commands when not pipelining */
-
- NON_SYNC_CMD_NON_PIPELINING,
-
/* I have been unable to find a statement about the use of pipelining
with AUTH, so to be on the safe side it is here, though I kind of feel
it should be up there with the synchronized commands. */
@@ -307,6 +311,97 @@ static void smtp_quit_handler(uschar **, uschar **);
static void smtp_rset_handler(void);
/*************************************************
+* Recheck synchronization *
+*************************************************/
+
+/* Synchronization checks can never be perfect because a packet may be on its
+way but not arrived when the check is done. Such checks can in any case only be
+done when TLS is not in use. Normally, the checks happen when commands are
+read: Exim ensures that there is no more input in the input buffer. In normal
+cases, the response to the command will be fast, and there is no further check.
+
+However, for some commands an ACL is run, and that can include delays. In those
+cases, it is useful to do another check on the input just before sending the
+response. This also applies at the start of a connection. This function does
+that check by means of the select() function, as long as the facility is not
+disabled or inappropriate. A failure of select() is ignored.
+
+When there is unwanted input, we read it so that it appears in the log of the
+error.
+
+Arguments: none
+Returns: TRUE if all is well; FALSE if there is input pending
+*/
+
+static BOOL
+check_sync(void)
+{
+int fd, rc;
+fd_set fds;
+struct timeval tzero;
+
+if (!smtp_enforce_sync || sender_host_address == NULL ||
+ sender_host_notsocket || tls_in.active >= 0)
+ return TRUE;
+
+fd = fileno(smtp_in);
+FD_ZERO(&fds);
+FD_SET(fd, &fds);
+tzero.tv_sec = 0;
+tzero.tv_usec = 0;
+rc = select(fd + 1, (SELECT_ARG2_TYPE *)&fds, NULL, NULL, &tzero);
+
+if (rc <= 0) return TRUE; /* Not ready to read */
+rc = smtp_getc();
+if (rc < 0) return TRUE; /* End of file or error */
+
+smtp_ungetc(rc);
+rc = smtp_inend - smtp_inptr;
+if (rc > 150) rc = 150;
+smtp_inptr[rc] = 0;
+return FALSE;
+}
+
+
+
+/*************************************************
+* Log incomplete transactions *
+*************************************************/
+
+/* This function is called after a transaction has been aborted by RSET, QUIT,
+connection drops or other errors. It logs the envelope information received
+so far in order to preserve address verification attempts.
+
+Argument: string to indicate what aborted the transaction
+Returns: nothing
+*/
+
+static void
+incomplete_transaction_log(uschar *what)
+{
+if (sender_address == NULL || /* No transaction in progress */
+ !LOGGING(smtp_incomplete_transaction))
+ return;
+
+/* Build list of recipients for logging */
+
+if (recipients_count > 0)
+ {
+ int i;
+ raw_recipients = store_get(recipients_count * sizeof(uschar *));
+ for (i = 0; i < recipients_count; i++)
+ raw_recipients[i] = recipients_list[i].address;
+ raw_recipients_count = recipients_count;
+ }
+
+log_write(L_smtp_incomplete_transaction, LOG_MAIN|LOG_SENDER|LOG_RECIPIENTS,
+ "%s incomplete transaction (%s)", host_and_ident(TRUE), what);
+}
+
+
+
+
+/*************************************************
* SMTP version of getc() *
*************************************************/
@@ -394,6 +489,22 @@ for(;;)
receive_getc = lwr_receive_getc;
receive_ungetc = lwr_receive_ungetc;
+ /* Unless PIPELINING was offered, there should be no next command
+ until after we ack that chunk */
+
+ if (!pipelining_advertised && !check_sync())
+ {
+ incomplete_transaction_log(US"sync failure");
+ log_write(0, LOG_MAIN|LOG_REJECT, "SMTP protocol synchronization error "
+ "(next input sent too soon: pipelining was not advertised): "
+ "rejected \"%s\" %s next input=\"%s\"",
+ smtp_cmd_buffer, host_and_ident(TRUE),
+ string_printing(smtp_inptr));
+ (void) synprot_error(L_smtp_protocol_error, 554, NULL,
+ US"SMTP synchronization error");
+ goto repeat_until_rset;
+ }
+
/* If not the last, ack the received chunk. The last response is delayed
until after the data ACL decides on it */
@@ -1257,60 +1368,6 @@ return OTHER_CMD;
/*************************************************
-* Recheck synchronization *
-*************************************************/
-
-/* Synchronization checks can never be perfect because a packet may be on its
-way but not arrived when the check is done. Such checks can in any case only be
-done when TLS is not in use. Normally, the checks happen when commands are
-read: Exim ensures that there is no more input in the input buffer. In normal
-cases, the response to the command will be fast, and there is no further check.
-
-However, for some commands an ACL is run, and that can include delays. In those
-cases, it is useful to do another check on the input just before sending the
-response. This also applies at the start of a connection. This function does
-that check by means of the select() function, as long as the facility is not
-disabled or inappropriate. A failure of select() is ignored.
-
-When there is unwanted input, we read it so that it appears in the log of the
-error.
-
-Arguments: none
-Returns: TRUE if all is well; FALSE if there is input pending
-*/
-
-static BOOL
-check_sync(void)
-{
-int fd, rc;
-fd_set fds;
-struct timeval tzero;
-
-if (!smtp_enforce_sync || sender_host_address == NULL ||
- sender_host_notsocket || tls_in.active >= 0)
- return TRUE;
-
-fd = fileno(smtp_in);
-FD_ZERO(&fds);
-FD_SET(fd, &fds);
-tzero.tv_sec = 0;
-tzero.tv_usec = 0;
-rc = select(fd + 1, (SELECT_ARG2_TYPE *)&fds, NULL, NULL, &tzero);
-
-if (rc <= 0) return TRUE; /* Not ready to read */
-rc = smtp_getc();
-if (rc < 0) return TRUE; /* End of file or error */
-
-smtp_ungetc(rc);
-rc = smtp_inend - smtp_inptr;
-if (rc > 150) rc = 150;
-smtp_inptr[rc] = 0;
-return FALSE;
-}
-
-
-
-/*************************************************
* Forced closedown of call *
*************************************************/
@@ -2635,43 +2692,6 @@ return yield;
/*************************************************
-* Log incomplete transactions *
-*************************************************/
-
-/* This function is called after a transaction has been aborted by RSET, QUIT,
-connection drops or other errors. It logs the envelope information received
-so far in order to preserve address verification attempts.
-
-Argument: string to indicate what aborted the transaction
-Returns: nothing
-*/
-
-static void
-incomplete_transaction_log(uschar *what)
-{
-if (sender_address == NULL || /* No transaction in progress */
- !LOGGING(smtp_incomplete_transaction))
- return;
-
-/* Build list of recipients for logging */
-
-if (recipients_count > 0)
- {
- int i;
- raw_recipients = store_get(recipients_count * sizeof(uschar *));
- for (i = 0; i < recipients_count; i++)
- raw_recipients[i] = recipients_list[i].address;
- raw_recipients_count = recipients_count;
- }
-
-log_write(L_smtp_incomplete_transaction, LOG_MAIN|LOG_SENDER|LOG_RECIPIENTS,
- "%s incomplete transaction (%s)", host_and_ident(TRUE), what);
-}
-
-
-
-
-/*************************************************
* Send SMTP response, possibly multiline *
*************************************************/
diff --git a/test/confs/0577 b/test/confs/0577
new file mode 100644
index 000000000..261a096f1
--- /dev/null
+++ b/test/confs/0577
@@ -0,0 +1 @@
+.include confs/TESTNUM./aaa
diff --git a/test/confs/0903./aaa b/test/confs/0577./aaa
index 746f316bf..746f316bf 100644
--- a/test/confs/0903./aaa
+++ b/test/confs/0577./aaa
diff --git a/test/confs/0903./bbb b/test/confs/0577./bbb
index e69de29bb..e69de29bb 100644
--- a/test/confs/0903./bbb
+++ b/test/confs/0577./bbb
diff --git a/test/confs/0901 b/test/confs/0901
index 1bb987150..c2eb5cca6 120000..100644
--- a/test/confs/0901
+++ b/test/confs/0901
@@ -1 +1,121 @@
-0900 \ No newline at end of file
+# Exim test configuration 0901
+SERVER=
+SRV=
+LIST=
+ALLOW=
+
+exim_path = EXIM_PATH
+keep_environment =
+host_lookup_order = bydns
+spool_directory = DIR/spool
+log_file_path = DIR/spool/log/SERVER%slog
+gecos_pattern = ""
+gecos_name = CALLER_NAME
+chunking_advertise_hosts = *
+tls_advertise_hosts = ${if eq {SRV}{tls} {*}}
+
+pipelining_advertise_hosts = :
+
+# ----- Main settings -----
+
+primary_hostname = testhost.test.ex
+domainlist local_domains = @ : test.ex
+
+acl_smtp_rcpt = check_recipient
+acl_smtp_data_prdr = check_prdr
+acl_smtp_data = check_data
+trusted_users = CALLER
+queue_only
+smtp_receive_timeout = 2s
+log_selector = +received_recipients
+
+.ifdef _OPT_MAIN_TLS_CERTIFICATE
+tls_certificate = ${if eq {SERVER}{server}{DIR/aux-fixed/cert1}fail}
+tls_privatekey = ${if eq {SERVER}{server}{DIR/aux-fixed/cert1}fail}
+.endif
+
+ALLOW
+
+# ----- ACL -----
+
+begin acl
+
+check_recipient:
+ accept hosts = :
+ accept domains = +local_domains
+ deny message = relay not permitted
+
+check_prdr:
+ accept local_parts = good
+ deny
+
+check_data:
+ warn message = X-acl-message-linecount: $message_linecount
+ accept
+
+# ----- Routers -----
+
+begin routers
+
+to_server:
+ driver = accept
+ condition = ${if !eq {SERVER}{server}}
+ transport = remote_smtp${if eq {OPT}{dkim} {_dkim}}
+ errors_to = ""
+
+fail_remote_domains:
+ driver = redirect
+ domains = ! +local_domains
+ data = :fail: unrouteable mail domain "$domain"
+
+localuser:
+ driver = accept
+ check_local_user
+ transport = local_delivery
+ headers_add = X-local-user: uid=$local_user_uid gid=$local_user_gid
+
+
+# ----- Transports -----
+
+begin transports
+
+local_delivery:
+ driver = appendfile
+ delivery_date_add
+ envelope_to_add
+ file = DIR/test-mail/$local_part
+ headers_add = "X-body-linecount: $body_linecount\n\
+ X-message-linecount: $message_linecount\n\
+ X-received-count: $received_count"
+ return_path_add
+
+remote_smtp:
+ driver = smtp
+ hosts = 127.0.0.1
+ port = PORT_S
+ allow_localhost
+ command_timeout = 2s
+ final_timeout = 2s
+
+remote_smtp_dkim:
+ driver = smtp
+ hosts = 127.0.0.1
+ port = PORT_S
+ allow_localhost
+ command_timeout = 2s
+ final_timeout = 2s
+
+.ifdef OPT
+ dkim_domain = test.ex
+ dkim_selector = sel
+ dkim_private_key = DIR/aux-fixed/dkim/dkim.private
+.ifndef HEADERS_MAXSIZE
+ dkim_sign_headers = LIST
+.endif
+.endif
+
+# ----- Retry -----
+
+begin retry
+* * F,30m,5m;
+# End
diff --git a/test/confs/0903 b/test/confs/0903
deleted file mode 100644
index 017424e24..000000000
--- a/test/confs/0903
+++ /dev/null
@@ -1 +0,0 @@
-.include confs/0903./aaa
diff --git a/test/confs/0902 b/test/confs/0904
index 1bb987150..1bb987150 120000
--- a/test/confs/0902
+++ b/test/confs/0904
diff --git a/test/confs/0905 b/test/confs/0905
new file mode 120000
index 000000000..1bb987150
--- /dev/null
+++ b/test/confs/0905
@@ -0,0 +1 @@
+0900 \ No newline at end of file
diff --git a/test/log/0901 b/test/log/0901
index 92e4ae01a..01135920b 100644
--- a/test/log/0901
+++ b/test/log/0901
@@ -1,38 +1,13 @@
-1999-03-02 09:44:33 10HmaX-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for a@test.ex
-1999-03-02 09:44:33 10HmaX-0005vi-00 => a@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1] K C="250 OK"
-1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
-1999-03-02 09:44:33 10HmaY-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for b@test.ex
-1999-03-02 09:44:33 10HmaY-0005vi-00 == b@test.ex R=to_server T=remote_smtp defer (dd): Connection timed out H=127.0.0.1 [127.0.0.1]: SMTP timeout after end of data (ddd bytes written)
-1999-03-02 09:44:33 10HmaZ-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for c@test.ex
-1999-03-02 09:44:33 10HmaZ-0005vi-00 => c@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1] K C="250 OK"
-1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed
-1999-03-02 09:44:33 10HmbA-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for d@test.ex
-1999-03-02 09:44:33 10HmbA-0005vi-00 ** d@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after end of data: 500 oops
-1999-03-02 09:44:33 10HmbA-0005vi-00 d@test.ex: error ignored
-1999-03-02 09:44:33 10HmbA-0005vi-00 Completed
-1999-03-02 09:44:33 10HmbB-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for e@test.ex
-1999-03-02 09:44:33 10HmbB-0005vi-00 == e@test.ex R=to_server T=remote_smtp defer (-46) H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after end of data: 400 not right now
-1999-03-02 09:44:33 10HmbC-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for p@test.ex
-1999-03-02 09:44:33 10HmbC-0005vi-00 => p@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1] K C="250 OK bdat"
-1999-03-02 09:44:33 10HmbC-0005vi-00 Completed
-1999-03-02 09:44:33 10HmbD-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for q@test.ex
-1999-03-02 09:44:33 10HmbD-0005vi-00 == q@test.ex R=to_server T=remote_smtp defer (dd): Connection timed out H=127.0.0.1 [127.0.0.1]: SMTP timeout after pipelined end of data (ddd bytes written)
-1999-03-02 09:44:33 10HmbE-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for r@test.ex
-1999-03-02 09:44:33 10HmbE-0005vi-00 => r@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1] K C="250 OK bdat"
-1999-03-02 09:44:33 10HmbE-0005vi-00 Completed
-1999-03-02 09:44:33 10HmbF-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for s@test.ex
-1999-03-02 09:44:33 10HmbF-0005vi-00 ** s@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined end of data: 550 unacceptable mail-from
-1999-03-02 09:44:33 10HmbF-0005vi-00 s@test.ex: error ignored
-1999-03-02 09:44:33 10HmbF-0005vi-00 Completed
-1999-03-02 09:44:33 10HmbG-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for s1@test.ex
-1999-03-02 09:44:33 10HmbG-0005vi-00 == s1@test.ex R=to_server T=remote_smtp defer (-45) H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined end of data: 450 greylisted mail-from
-1999-03-02 09:44:33 10HmbH-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for t@test.ex
-1999-03-02 09:44:33 10HmbH-0005vi-00 ** t@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after RCPT TO:<t@test.ex>: 550 no such recipient
-1999-03-02 09:44:33 10HmbH-0005vi-00 t@test.ex: error ignored
-1999-03-02 09:44:33 10HmbH-0005vi-00 Completed
-1999-03-02 09:44:33 10HmbI-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for u@test.ex
-1999-03-02 09:44:33 10HmbI-0005vi-00 ** u@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined end of data: 500 oops bdat
-1999-03-02 09:44:33 10HmbI-0005vi-00 u@test.ex: error ignored
-1999-03-02 09:44:33 10HmbI-0005vi-00 Completed
-1999-03-02 09:44:33 10HmbJ-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for v@test.ex
-1999-03-02 09:44:33 10HmbJ-0005vi-00 == v@test.ex R=to_server T=remote_smtp defer (-46) H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined end of data: 400 not right now bdat
+
+******** SERVER ********
+1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= someone1@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= someone2@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
+1999-03-02 09:44:33 10HmaZ-0005vi-00 <= someone3@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
+1999-03-02 09:44:33 10HmbA-0005vi-00 SMTP data timeout (message abandoned) on connection from (tester) [127.0.0.1] F=<someone4@some.domain>
+1999-03-02 09:44:33 SMTP connection from (tester) [127.0.0.1] lost while reading message data
+1999-03-02 09:44:33 SMTP connection from (tester) [127.0.0.1] lost while reading message data
+1999-03-02 09:44:33 10HmbB-0005vi-00 <= someone8@some.domain H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@test.ex
+1999-03-02 09:44:33 SMTP protocol synchronization error (next input sent too soon: pipelining was not advertised): rejected "bdat 1" H=(tester) [127.0.0.1] next input="bdat 87 last\r\n"
+1999-03-02 09:44:33 SMTP call from (tester) [127.0.0.1] dropped: too many syntax or protocol errors (last command was "From: Sam@random.com")
+1999-03-02 09:44:33 SMTP connection from (tester) [127.0.0.1] lost while reading message data (header)
diff --git a/test/log/0904 b/test/log/0904
new file mode 100644
index 000000000..92e4ae01a
--- /dev/null
+++ b/test/log/0904
@@ -0,0 +1,38 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for a@test.ex
+1999-03-02 09:44:33 10HmaX-0005vi-00 => a@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1] K C="250 OK"
+1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for b@test.ex
+1999-03-02 09:44:33 10HmaY-0005vi-00 == b@test.ex R=to_server T=remote_smtp defer (dd): Connection timed out H=127.0.0.1 [127.0.0.1]: SMTP timeout after end of data (ddd bytes written)
+1999-03-02 09:44:33 10HmaZ-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for c@test.ex
+1999-03-02 09:44:33 10HmaZ-0005vi-00 => c@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1] K C="250 OK"
+1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbA-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for d@test.ex
+1999-03-02 09:44:33 10HmbA-0005vi-00 ** d@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after end of data: 500 oops
+1999-03-02 09:44:33 10HmbA-0005vi-00 d@test.ex: error ignored
+1999-03-02 09:44:33 10HmbA-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbB-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for e@test.ex
+1999-03-02 09:44:33 10HmbB-0005vi-00 == e@test.ex R=to_server T=remote_smtp defer (-46) H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after end of data: 400 not right now
+1999-03-02 09:44:33 10HmbC-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for p@test.ex
+1999-03-02 09:44:33 10HmbC-0005vi-00 => p@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1] K C="250 OK bdat"
+1999-03-02 09:44:33 10HmbC-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbD-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for q@test.ex
+1999-03-02 09:44:33 10HmbD-0005vi-00 == q@test.ex R=to_server T=remote_smtp defer (dd): Connection timed out H=127.0.0.1 [127.0.0.1]: SMTP timeout after pipelined end of data (ddd bytes written)
+1999-03-02 09:44:33 10HmbE-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for r@test.ex
+1999-03-02 09:44:33 10HmbE-0005vi-00 => r@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1] K C="250 OK bdat"
+1999-03-02 09:44:33 10HmbE-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbF-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for s@test.ex
+1999-03-02 09:44:33 10HmbF-0005vi-00 ** s@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined end of data: 550 unacceptable mail-from
+1999-03-02 09:44:33 10HmbF-0005vi-00 s@test.ex: error ignored
+1999-03-02 09:44:33 10HmbF-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbG-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for s1@test.ex
+1999-03-02 09:44:33 10HmbG-0005vi-00 == s1@test.ex R=to_server T=remote_smtp defer (-45) H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined end of data: 450 greylisted mail-from
+1999-03-02 09:44:33 10HmbH-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for t@test.ex
+1999-03-02 09:44:33 10HmbH-0005vi-00 ** t@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after RCPT TO:<t@test.ex>: 550 no such recipient
+1999-03-02 09:44:33 10HmbH-0005vi-00 t@test.ex: error ignored
+1999-03-02 09:44:33 10HmbH-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbI-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for u@test.ex
+1999-03-02 09:44:33 10HmbI-0005vi-00 ** u@test.ex R=to_server T=remote_smtp H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined end of data: 500 oops bdat
+1999-03-02 09:44:33 10HmbI-0005vi-00 u@test.ex: error ignored
+1999-03-02 09:44:33 10HmbI-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbJ-0005vi-00 <= sender@source.dom U=root P=local-bsmtp S=sss for v@test.ex
+1999-03-02 09:44:33 10HmbJ-0005vi-00 == v@test.ex R=to_server T=remote_smtp defer (-46) H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined end of data: 400 not right now bdat
diff --git a/test/log/0902 b/test/log/0905
index 53c5697ef..53c5697ef 100644
--- a/test/log/0902
+++ b/test/log/0905
diff --git a/test/rejectlog/0901 b/test/rejectlog/0901
new file mode 100644
index 000000000..a7f8f0692
--- /dev/null
+++ b/test/rejectlog/0901
@@ -0,0 +1,8 @@
+
+******** SERVER ********
+1999-03-02 09:44:33 SMTP protocol synchronization error (next input sent too soon: pipelining was not advertised): rejected "bdat 1" H=(tester) [127.0.0.1] next input="bdat 87 last\r\n"
+Envelope-from: <someone9@some.domain>
+Envelope-to: <CALLER@test.ex>
+1999-03-02 09:44:33 SMTP call from (tester) [127.0.0.1] dropped: too many syntax or protocol errors (last command was "From: Sam@random.com")
+Envelope-from: <someone9@some.domain>
+Envelope-to: <CALLER@test.ex>
diff --git a/test/scripts/0000-Basic/0903 b/test/scripts/0000-Basic/0577
index 1bd510ae3..1bd510ae3 100644
--- a/test/scripts/0000-Basic/0903
+++ b/test/scripts/0000-Basic/0577
diff --git a/test/scripts/0000-Basic/0901 b/test/scripts/0000-Basic/0901
index 2157e61a8..a52359966 100644
--- a/test/scripts/0000-Basic/0901
+++ b/test/scripts/0000-Basic/0901
@@ -1,387 +1,214 @@
-# CHUNKING transmission, short messages
-#
-# Start with non-pipelined cases
-#
-# Basic short message
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250 CHUNKING
-MAIL FROM
-250 OK
-RCPT TO
-250 OK
-BDAT 329 LAST
-*data 329
-250 OK
-QUIT
-225 OK
-*eof
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<a@test.ex>
-DATA
-Subject: foo
-
-data
-.
-QUIT
-****
-#
-# Error case: server wrongly expected more data, client gets timeout for data-ack
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250 CHUNKING
-MAIL FROM
-250 good mail cmd
-RCPT TO
-250 acceptable rcpt cmd
-BDAT 329 LAST
-*data 330
-250 OK got that data
-QUIT
-225 OK quitting
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<b@test.ex>
-DATA
-Subject: foo
-
-data
-.
-QUIT
-****
-#
-# Error case: server wrongly expected less data
-# client get the data-ack, sends quit - but server
-# sees a munged quit due to the outstanding data tail
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250 CHUNKING
-MAIL FROM
-250 OK
-RCPT TO
-250 OK
-BDAT 329 LAST
-*data 328
-250 OK
-QUIT
-225 OK
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<c@test.ex>
-DATA
-Subject: foo
-
-data
-.
-QUIT
-****
-#
-# server rejects BDAT cmd
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250 CHUNKING
-MAIL FROM
-250 OK
-RCPT TO
-250 OK
-BDAT 329 LAST
-*data 329
-500 oops
-QUIT
-225 OK
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<d@test.ex>
-DATA
-Subject: foo
+# CHUNKING reception, no pipelining
+exim -DSERVER=server -bd -oX PORT_D
+****
+#
+# plain, small message (no body)
+client 127.0.0.1 PORT_D
+??? 220
+ehlo tester
+??? 250-
+??? 250-SIZE
+??? 250-8BITMIME
+??? 250-CHUNKING
+??? 250 HELP
+mail from:someone1@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 88 last
+To: Susan@random.com
+From: Sam@random.com
+Subject: This is a bodyless test message
-data
-.
-QUIT
-****
-#
-# server tmp-rejects BDAT cmd
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250 CHUNKING
-MAIL FROM
-250 OK
-RCPT TO
-250 OK
-BDAT 329 LAST
-*data 329
-400 not right now
-QUIT
-225 OK
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<e@test.ex>
-DATA
-Subject: foo
+??? 250-
+??? 250
+quit
+??? 221
+****
+#
+# plain, small message (with body)
+# nonlast 1st bdat, noop, last-bdat(0)
+# immediate followon 2nd message
+client 127.0.0.1 PORT_D
+??? 220
+ehlo tester
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250
+mail from:someone2@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 100
+To: Susan@random.com
+From: Sam@random.com
+Subject: This is a bodyfull test message
-data
-.
-QUIT
-****
-#
-#
-###################################################
-#
-# Pipelined cases
-#
-# Basic short message
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM
-RCPT TO
-BDAT 329 LAST
-*data 329
-250 OK mail
-250 OK rcpt
-250 OK bdat
-QUIT
-225 OK
-*eof
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<p@test.ex>
-DATA
-Subject: foo
+1234567890
+??? 250
+noop
+??? 250
+bdat 0 last
+??? 250-
+??? 250
+mail from:someone3@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 10
+To: Susan@bdat 78 last
+??? 250
+random.com
+From: Sam@random.com
+Subject: This is a bodyless test message
-data
-.
-QUIT
-****
-#
-# Error case: server wrongly expected more data, client gets timeout for data-ack
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM
-RCPT TO
-BDAT 329 LAST
-*data 330
-250 good mail cmd
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<q@test.ex>
-DATA
-Subject: foo
+??? 250-
+??? 250
+quit
+??? 221
+****
+#
+# not enough data in chunk
+#
+client 127.0.0.1 PORT_D
+??? 220
+ehlo tester
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250
+mail from:someone4@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 89 last
+To: Susan@random.com
+From: Sam@random.com
+Subject: This is a bodyless test message
-data
-.
-QUIT
-****
-#
-# Error case: server wrongly expected less data
-# client get the data-ack, sends quit - but server
-# sees a munged quit due to the outstanding data tail
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM
-RCPT TO
-BDAT 329 LAST
-*data 328
-250 OK mail
-250 OK rcpt
-250 OK bdat
-QUIT
-225 OK
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<r@test.ex>
-DATA
-Subject: foo
+??? 421
+****
+#
+# protocol failure cases
+#
+client 127.0.0.1 PORT_D
+??? 220
+ehlo tester
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250
+mail from:someone5@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 88
+To: Susan@random.com
+From: Sam@random.com
+Subject: This is a bodyless test message
-data
-.
-QUIT
-****
-#
-# server rejects MAIL cmd
-# transport coding does not handle the possible RSET-and-another transaction,
-# but always QUITs
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM
-RCPT TO
-BDAT 329 LAST
-*data 329
-550 unacceptable mail-from
-550 rcpt ungood lacking mail-from
-500 bdat ungood lacking mail-from
-QUIT
-225 OK
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<s@test.ex>
-DATA
-Subject: foo
+??? 250
+bdat 0
+??? 504
+quit
+??? 221
+****
+#
+# followon EHLO and another message
+client 127.0.0.1 PORT_D
+??? 220
+ehlo tester
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250
+mail from:someone6@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 88
+To: Susan@random.com
+From: Sam@random.com
+Subject: This is a bodyless test message
+??? 250
data
-.
-QUIT
-****
-#
-# server tmp-rejects MAIL cmd
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM
-RCPT TO
-BDAT 330 LAST
-*data 330
-450 greylisted mail-from
-550 rcpt ungood lacking mail-from
-500 bdat ungood lacking mail-from
-QUIT
-225 OK
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<s1@test.ex>
-DATA
-Subject: foo
+??? 503
+RSET
+??? 250
+EHLO tester
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250
+mail from:someone7@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 88
+To: Susan@random.com
+From: Sam@random.com
+Subject: This is a bodyless test message
+??? 250
data
-.
-QUIT
-****
-#
-# server rejects RCPT cmd
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM
-RCPT TO
-BDAT 329 LAST
-*data 329
-250 OK mail
-550 no such recipient
-500 oops bdat
-QUIT
-225 OK
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<t@test.ex>
-DATA
-Subject: foo
-
+??? 503
data
-.
-QUIT
-****
-#
-# server rejects BDAT cmd
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM
-RCPT TO
-BDAT 329 LAST
-*data 329
-250 OK mail
-250 OK rcpt
-500 oops bdat
-QUIT
-225 OK
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<u@test.ex>
-DATA
-Subject: foo
+??? 503
+quit
+??? 221
+****
+#
+# plain, small message (no body), chunk data with bdat line
+client 127.0.0.1 PORT_D
+??? 220
+ehlo tester
+??? 250-
+??? 250-SIZE
+??? 250-8BITMIME
+??? 250-CHUNKING
+??? 250 HELP
+mail from:someone8@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 88 last\r\nTo: Susan@random.com
+From: Sam@random.com
+Subject: This is a bodyless test message
-data
-.
-QUIT
-****
-#
-# server tmp-rejects BDAT cmd
-server PORT_S
-220 Greetings
-EHLO
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM
-RCPT TO
-BDAT 329 LAST
-*data 329
-250 OK mail
-250 OK rcpt
-400 not right now bdat
-QUIT
-225 OK
-****
-sudo exim -odf -bS
-EHLO test
-MAIL FROM:<sender@source.dom>
-RCPT TO:<v@test.ex>
-DATA
-Subject: foo
+??? 250-
+??? 250
+quit
+??? 221
+****
+#
+# plain, small message (no body), 2 chunks, pipeline sync error for 2nd
+client 127.0.0.1 PORT_D
+??? 220
+ehlo tester
+??? 250-
+??? 250-SIZE
+??? 250-8BITMIME
+??? 250-CHUNKING
+??? 250 HELP
+mail from:someone9@some.domain
+??? 250
+rcpt to:CALLER@test.ex
+??? 250
+bdat 1\r\nTbdat 87 last
+To: Susan@random.com
+From: Sam@random.com
+Subject: This is a bodyless test message
-data
-.
-QUIT
+??? 554 SMTP synchronization error
****
#
#
+killdaemon
no_msglog_check
diff --git a/test/scripts/0000-Basic/0904 b/test/scripts/0000-Basic/0904
new file mode 100644
index 000000000..2157e61a8
--- /dev/null
+++ b/test/scripts/0000-Basic/0904
@@ -0,0 +1,387 @@
+# CHUNKING transmission, short messages
+#
+# Start with non-pipelined cases
+#
+# Basic short message
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250 CHUNKING
+MAIL FROM
+250 OK
+RCPT TO
+250 OK
+BDAT 329 LAST
+*data 329
+250 OK
+QUIT
+225 OK
+*eof
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<a@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# Error case: server wrongly expected more data, client gets timeout for data-ack
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250 CHUNKING
+MAIL FROM
+250 good mail cmd
+RCPT TO
+250 acceptable rcpt cmd
+BDAT 329 LAST
+*data 330
+250 OK got that data
+QUIT
+225 OK quitting
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<b@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# Error case: server wrongly expected less data
+# client get the data-ack, sends quit - but server
+# sees a munged quit due to the outstanding data tail
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250 CHUNKING
+MAIL FROM
+250 OK
+RCPT TO
+250 OK
+BDAT 329 LAST
+*data 328
+250 OK
+QUIT
+225 OK
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<c@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# server rejects BDAT cmd
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250 CHUNKING
+MAIL FROM
+250 OK
+RCPT TO
+250 OK
+BDAT 329 LAST
+*data 329
+500 oops
+QUIT
+225 OK
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<d@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# server tmp-rejects BDAT cmd
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250 CHUNKING
+MAIL FROM
+250 OK
+RCPT TO
+250 OK
+BDAT 329 LAST
+*data 329
+400 not right now
+QUIT
+225 OK
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<e@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+#
+###################################################
+#
+# Pipelined cases
+#
+# Basic short message
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM
+RCPT TO
+BDAT 329 LAST
+*data 329
+250 OK mail
+250 OK rcpt
+250 OK bdat
+QUIT
+225 OK
+*eof
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<p@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# Error case: server wrongly expected more data, client gets timeout for data-ack
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM
+RCPT TO
+BDAT 329 LAST
+*data 330
+250 good mail cmd
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<q@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# Error case: server wrongly expected less data
+# client get the data-ack, sends quit - but server
+# sees a munged quit due to the outstanding data tail
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM
+RCPT TO
+BDAT 329 LAST
+*data 328
+250 OK mail
+250 OK rcpt
+250 OK bdat
+QUIT
+225 OK
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<r@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# server rejects MAIL cmd
+# transport coding does not handle the possible RSET-and-another transaction,
+# but always QUITs
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM
+RCPT TO
+BDAT 329 LAST
+*data 329
+550 unacceptable mail-from
+550 rcpt ungood lacking mail-from
+500 bdat ungood lacking mail-from
+QUIT
+225 OK
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<s@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# server tmp-rejects MAIL cmd
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM
+RCPT TO
+BDAT 330 LAST
+*data 330
+450 greylisted mail-from
+550 rcpt ungood lacking mail-from
+500 bdat ungood lacking mail-from
+QUIT
+225 OK
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<s1@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# server rejects RCPT cmd
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM
+RCPT TO
+BDAT 329 LAST
+*data 329
+250 OK mail
+550 no such recipient
+500 oops bdat
+QUIT
+225 OK
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<t@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# server rejects BDAT cmd
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM
+RCPT TO
+BDAT 329 LAST
+*data 329
+250 OK mail
+250 OK rcpt
+500 oops bdat
+QUIT
+225 OK
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<u@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+# server tmp-rejects BDAT cmd
+server PORT_S
+220 Greetings
+EHLO
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM
+RCPT TO
+BDAT 329 LAST
+*data 329
+250 OK mail
+250 OK rcpt
+400 not right now bdat
+QUIT
+225 OK
+****
+sudo exim -odf -bS
+EHLO test
+MAIL FROM:<sender@source.dom>
+RCPT TO:<v@test.ex>
+DATA
+Subject: foo
+
+data
+.
+QUIT
+****
+#
+#
+no_msglog_check
diff --git a/test/scripts/0000-Basic/0902 b/test/scripts/0000-Basic/0905
index 5be294087..5be294087 100644
--- a/test/scripts/0000-Basic/0902
+++ b/test/scripts/0000-Basic/0905
diff --git a/test/stdout/0901 b/test/stdout/0901
index a19787d12..0e35d76c3 100644
--- a/test/stdout/0901
+++ b/test/stdout/0901
@@ -1,199 +1,280 @@
-
-******** SERVER ********
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250 CHUNKING
-MAIL FROM:<>
-250 OK
-RCPT TO:<a@test.ex>
-250 OK
-BDAT 329 LAST
-250 OK
-QUIT
-225 OK
-Expected EOF read from client
+Connecting to 127.0.0.1 port 1225 ... connected
+??? 220
+<<< 220 testhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> ehlo tester
+??? 250-
+<<< 250-testhost.test.ex Hello tester [127.0.0.1]
+??? 250-SIZE
+<<< 250-SIZE 52428800
+??? 250-8BITMIME
+<<< 250-8BITMIME
+??? 250-CHUNKING
+<<< 250-CHUNKING
+??? 250 HELP
+<<< 250 HELP
+>>> mail from:someone1@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 88 last
+>>> To: Susan@random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyless test message
+>>>
+??? 250-
+<<< 250- 88 byte chunk, total 88
+??? 250
+<<< 250 OK id=10HmaX-0005vi-00
+>>> quit
+??? 221
+<<< 221 testhost.test.ex closing connection
End of script
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250 CHUNKING
-MAIL FROM:<>
-250 good mail cmd
-RCPT TO:<b@test.ex>
-250 acceptable rcpt cmd
-BDAT 329 LAST
-Unxpected EOF read from client
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250 CHUNKING
-MAIL FROM:<>
-250 OK
-RCPT TO:<c@test.ex>
-250 OK
-BDAT 329 LAST
-250 OK
-
-Comparison failed - bailing out
-Expected: QUIT
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250 CHUNKING
-MAIL FROM:<>
-250 OK
-RCPT TO:<d@test.ex>
-250 OK
-BDAT 329 LAST
-500 oops
-QUIT
-225 OK
+Connecting to 127.0.0.1 port 1225 ... connected
+??? 220
+<<< 220 testhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> ehlo tester
+??? 250-
+<<< 250-testhost.test.ex Hello tester [127.0.0.1]
+??? 250-
+<<< 250-SIZE 52428800
+??? 250-
+<<< 250-8BITMIME
+??? 250-
+<<< 250-CHUNKING
+??? 250
+<<< 250 HELP
+>>> mail from:someone2@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 100
+>>> To: Susan@random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyfull test message
+>>>
+>>> 1234567890
+??? 250
+<<< 250 100 byte chunk received
+>>> noop
+??? 250
+<<< 250 OK
+>>> bdat 0 last
+??? 250-
+<<< 250- 0 byte chunk, total 100
+??? 250
+<<< 250 OK id=10HmaY-0005vi-00
+>>> mail from:someone3@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 10
+>>> To: Susan@bdat 78 last
+??? 250
+<<< 250 10 byte chunk received
+>>> random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyless test message
+>>>
+??? 250-
+<<< 250- 78 byte chunk, total 88
+??? 250
+<<< 250 OK id=10HmaZ-0005vi-00
+>>> quit
+??? 221
+<<< 221 testhost.test.ex closing connection
End of script
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250 CHUNKING
-MAIL FROM:<>
-250 OK
-RCPT TO:<e@test.ex>
-250 OK
-BDAT 329 LAST
-400 not right now
-QUIT
-225 OK
+Connecting to 127.0.0.1 port 1225 ... connected
+??? 220
+<<< 220 testhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> ehlo tester
+??? 250-
+<<< 250-testhost.test.ex Hello tester [127.0.0.1]
+??? 250-
+<<< 250-SIZE 52428800
+??? 250-
+<<< 250-8BITMIME
+??? 250-
+<<< 250-CHUNKING
+??? 250
+<<< 250 HELP
+>>> mail from:someone4@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 89 last
+>>> To: Susan@random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyless test message
+>>>
+??? 421
+<<< 421 testhost.test.ex SMTP incoming data timeout - closing connection.
End of script
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM:<>
-RCPT TO:<p@test.ex>
-BDAT 329 LAST
-250 OK mail
-250 OK rcpt
-250 OK bdat
-QUIT
-225 OK
-Expected EOF read from client
+Connecting to 127.0.0.1 port 1225 ... connected
+??? 220
+<<< 220 testhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> ehlo tester
+??? 250-
+<<< 250-testhost.test.ex Hello tester [127.0.0.1]
+??? 250-
+<<< 250-SIZE 52428800
+??? 250-
+<<< 250-8BITMIME
+??? 250-
+<<< 250-CHUNKING
+??? 250
+<<< 250 HELP
+>>> mail from:someone5@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 88
+>>> To: Susan@random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyless test message
+>>>
+??? 250
+<<< 250 88 byte chunk received
+>>> bdat 0
+??? 504
+<<< 504 zero size for BDAT command
+>>> quit
+??? 221
+<<< 221 testhost.test.ex closing connection
End of script
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM:<>
-RCPT TO:<q@test.ex>
-BDAT 329 LAST
-Unxpected EOF read from client
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM:<>
-RCPT TO:<r@test.ex>
-BDAT 329 LAST
-250 OK mail
-250 OK rcpt
-250 OK bdat
-
-Comparison failed - bailing out
-Expected: QUIT
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM:<>
-RCPT TO:<s@test.ex>
-BDAT 329 LAST
-550 unacceptable mail-from
-550 rcpt ungood lacking mail-from
-500 bdat ungood lacking mail-from
-QUIT
-225 OK
+Connecting to 127.0.0.1 port 1225 ... connected
+??? 220
+<<< 220 testhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> ehlo tester
+??? 250-
+<<< 250-testhost.test.ex Hello tester [127.0.0.1]
+??? 250-
+<<< 250-SIZE 52428800
+??? 250-
+<<< 250-8BITMIME
+??? 250-
+<<< 250-CHUNKING
+??? 250
+<<< 250 HELP
+>>> mail from:someone6@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 88
+>>> To: Susan@random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyless test message
+>>>
+??? 250
+<<< 250 88 byte chunk received
+>>> data
+??? 503
+<<< 503 only BDAT permissible after non-LAST BDAT
+>>> RSET
+??? 250
+<<< 250 Reset OK
+>>> EHLO tester
+??? 250-
+<<< 250-testhost.test.ex Hello tester [127.0.0.1]
+??? 250-
+<<< 250-SIZE 52428800
+??? 250-
+<<< 250-8BITMIME
+??? 250-
+<<< 250-CHUNKING
+??? 250
+<<< 250 HELP
+>>> mail from:someone7@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 88
+>>> To: Susan@random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyless test message
+>>>
+??? 250
+<<< 250 88 byte chunk received
+>>> data
+??? 503
+<<< 503 only BDAT permissible after non-LAST BDAT
+>>> data
+??? 503
+<<< 503 only RSET accepted now
+>>> quit
+??? 221
+<<< 221 testhost.test.ex closing connection
End of script
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM:<>
-RCPT TO:<s1@test.ex>
-BDAT 330 LAST
-450 greylisted mail-from
-550 rcpt ungood lacking mail-from
-500 bdat ungood lacking mail-from
-QUIT
-225 OK
+Connecting to 127.0.0.1 port 1225 ... connected
+??? 220
+<<< 220 testhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> ehlo tester
+??? 250-
+<<< 250-testhost.test.ex Hello tester [127.0.0.1]
+??? 250-SIZE
+<<< 250-SIZE 52428800
+??? 250-8BITMIME
+<<< 250-8BITMIME
+??? 250-CHUNKING
+<<< 250-CHUNKING
+??? 250 HELP
+<<< 250 HELP
+>>> mail from:someone8@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 88 last\r\nTo: Susan@random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyless test message
+>>>
+??? 250-
+<<< 250- 88 byte chunk, total 88
+??? 250
+<<< 250 OK id=10HmbB-0005vi-00
+>>> quit
+??? 221
+<<< 221 testhost.test.ex closing connection
End of script
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM:<>
-RCPT TO:<t@test.ex>
-BDAT 329 LAST
-250 OK mail
-550 no such recipient
-500 oops bdat
-QUIT
-225 OK
-End of script
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM:<>
-RCPT TO:<u@test.ex>
-BDAT 329 LAST
-250 OK mail
-250 OK rcpt
-500 oops bdat
-QUIT
-225 OK
-End of script
-Listening on port 1224 ...
-Connection request from [127.0.0.1]
-220 Greetings
-EHLO testhost.test.ex
-250-Hello there
-250-PIPELINING
-250 CHUNKING
-MAIL FROM:<>
-RCPT TO:<v@test.ex>
-BDAT 329 LAST
-250 OK mail
-250 OK rcpt
-400 not right now bdat
-QUIT
-225 OK
+Connecting to 127.0.0.1 port 1225 ... connected
+??? 220
+<<< 220 testhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> ehlo tester
+??? 250-
+<<< 250-testhost.test.ex Hello tester [127.0.0.1]
+??? 250-SIZE
+<<< 250-SIZE 52428800
+??? 250-8BITMIME
+<<< 250-8BITMIME
+??? 250-CHUNKING
+<<< 250-CHUNKING
+??? 250 HELP
+<<< 250 HELP
+>>> mail from:someone9@some.domain
+??? 250
+<<< 250 OK
+>>> rcpt to:CALLER@test.ex
+??? 250
+<<< 250 Accepted
+>>> bdat 1\r\nTbdat 87 last
+>>> To: Susan@random.com
+>>> From: Sam@random.com
+>>> Subject: This is a bodyless test message
+>>>
+??? 554 SMTP synchronization error
+<<< 554 SMTP synchronization error
End of script
diff --git a/test/stdout/0904 b/test/stdout/0904
new file mode 100644
index 000000000..a19787d12
--- /dev/null
+++ b/test/stdout/0904
@@ -0,0 +1,199 @@
+
+******** SERVER ********
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250 CHUNKING
+MAIL FROM:<>
+250 OK
+RCPT TO:<a@test.ex>
+250 OK
+BDAT 329 LAST
+250 OK
+QUIT
+225 OK
+Expected EOF read from client
+End of script
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250 CHUNKING
+MAIL FROM:<>
+250 good mail cmd
+RCPT TO:<b@test.ex>
+250 acceptable rcpt cmd
+BDAT 329 LAST
+Unxpected EOF read from client
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250 CHUNKING
+MAIL FROM:<>
+250 OK
+RCPT TO:<c@test.ex>
+250 OK
+BDAT 329 LAST
+250 OK
+
+Comparison failed - bailing out
+Expected: QUIT
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250 CHUNKING
+MAIL FROM:<>
+250 OK
+RCPT TO:<d@test.ex>
+250 OK
+BDAT 329 LAST
+500 oops
+QUIT
+225 OK
+End of script
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250 CHUNKING
+MAIL FROM:<>
+250 OK
+RCPT TO:<e@test.ex>
+250 OK
+BDAT 329 LAST
+400 not right now
+QUIT
+225 OK
+End of script
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM:<>
+RCPT TO:<p@test.ex>
+BDAT 329 LAST
+250 OK mail
+250 OK rcpt
+250 OK bdat
+QUIT
+225 OK
+Expected EOF read from client
+End of script
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM:<>
+RCPT TO:<q@test.ex>
+BDAT 329 LAST
+Unxpected EOF read from client
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM:<>
+RCPT TO:<r@test.ex>
+BDAT 329 LAST
+250 OK mail
+250 OK rcpt
+250 OK bdat
+
+Comparison failed - bailing out
+Expected: QUIT
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM:<>
+RCPT TO:<s@test.ex>
+BDAT 329 LAST
+550 unacceptable mail-from
+550 rcpt ungood lacking mail-from
+500 bdat ungood lacking mail-from
+QUIT
+225 OK
+End of script
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM:<>
+RCPT TO:<s1@test.ex>
+BDAT 330 LAST
+450 greylisted mail-from
+550 rcpt ungood lacking mail-from
+500 bdat ungood lacking mail-from
+QUIT
+225 OK
+End of script
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM:<>
+RCPT TO:<t@test.ex>
+BDAT 329 LAST
+250 OK mail
+550 no such recipient
+500 oops bdat
+QUIT
+225 OK
+End of script
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM:<>
+RCPT TO:<u@test.ex>
+BDAT 329 LAST
+250 OK mail
+250 OK rcpt
+500 oops bdat
+QUIT
+225 OK
+End of script
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Greetings
+EHLO testhost.test.ex
+250-Hello there
+250-PIPELINING
+250 CHUNKING
+MAIL FROM:<>
+RCPT TO:<v@test.ex>
+BDAT 329 LAST
+250 OK mail
+250 OK rcpt
+400 not right now bdat
+QUIT
+225 OK
+End of script
diff --git a/test/stdout/0902 b/test/stdout/0905
index 22d02212e..22d02212e 100644
--- a/test/stdout/0902
+++ b/test/stdout/0905