From 528fde2aff25fbe284332ad2ec4b8cb5fc8c7859 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 29 Apr 2012 18:22:56 +0100 Subject: [PATCH] Testsuite cases for basic cutthrough_delivery. Also fixed bug where a predata acl was required for cutthrough. --- src/src/smtp_in.c | 8 ++- test/confs/5400 | 42 ++++++++++++ test/confs/5401 | 50 ++++++++++++++ test/log/5400 | 3 + test/log/5401 | 3 + test/scripts/5400-cutthrough/5400 | 64 ++++++++++++++++++ test/scripts/5400-cutthrough/5401 | 27 ++++++++ test/stderr/5400 | 104 ++++++++++++++++++++++++++++++ test/stderr/5401 | 38 +++++++++++ test/stdout/5400 | 83 ++++++++++++++++++++++++ test/stdout/5401 | 35 ++++++++++ 11 files changed, 454 insertions(+), 3 deletions(-) create mode 100644 test/confs/5400 create mode 100644 test/confs/5401 create mode 100644 test/log/5400 create mode 100644 test/log/5401 create mode 100644 test/scripts/5400-cutthrough/5400 create mode 100644 test/scripts/5400-cutthrough/5401 create mode 100644 test/stderr/5400 create mode 100644 test/stderr/5401 create mode 100644 test/stdout/5400 create mode 100644 test/stdout/5401 diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 38162cd4c..9652a06e6 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -3773,12 +3773,14 @@ while (done <= 0) } /* If there is an ACL, re-check the synchronization afterwards, since the - ACL may have delayed. */ + ACL may have delayed. To handle cutthrough delivery enforce a dummy call + to get the DATA command sent. */ - if (acl_smtp_predata == NULL) rc = OK; else + if (acl_smtp_predata == NULL && cutthrough_fd < 0) rc = OK; else { + uschar * acl= acl_smtp_predata ? acl_smtp_predata : US"accept"; enable_dollar_recipients = TRUE; - rc = acl_check(ACL_WHERE_PREDATA, NULL, acl_smtp_predata, &user_msg, + rc = acl_check(ACL_WHERE_PREDATA, NULL, acl, &user_msg, &log_msg); enable_dollar_recipients = FALSE; if (rc == OK && !check_sync()) goto SYNC_FAILURE; diff --git a/test/confs/5400 b/test/confs/5400 new file mode 100644 index 000000000..15690b756 --- /dev/null +++ b/test/confs/5400 @@ -0,0 +1,42 @@ +# Exim test configuration 5400 + +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 ----- + +domainlist local_domains = test.ex : *.test.ex + +acl_smtp_rcpt = accept control = cutthrough_delivery + + +# ----- Routers ----- + +begin routers + +all: + driver = manualroute + domains = ! +local_domains + route_list = * 127.0.0.1 + self = send + transport = smtp + no_more + + +# ----- Transports ----- + +begin transports + +smtp: + driver = smtp + interface = HOSTIPV4 + port = PORT_S + + +# End diff --git a/test/confs/5401 b/test/confs/5401 new file mode 100644 index 000000000..db018a6d4 --- /dev/null +++ b/test/confs/5401 @@ -0,0 +1,50 @@ +# Exim test configuration 5401 + +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 ----- + +domainlist local_domains = test.ex : *.test.ex + +acl_smtp_rcpt = acl_rcpt + +# ----- ACLs ------- + +begin acl + +acl_rcpt: + accept control = cutthrough_delivery + verify = recipient + + +# ----- Routers ----- + +begin routers + +all: + driver = manualroute + domains = ! +local_domains + route_list = * 127.0.0.1 + self = send + transport = smtp + no_more + + +# ----- Transports ----- + +begin transports + +smtp: + driver = smtp + interface = HOSTIPV4 + port = PORT_S + + +# End diff --git a/test/log/5400 b/test/log/5400 new file mode 100644 index 000000000..6d38a372f --- /dev/null +++ b/test/log/5400 @@ -0,0 +1,3 @@ +1999-03-02 09:44:33 10HmaX-0005vi-00 >> userx@domain.com R=all T=smtp +1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss +1999-03-02 09:44:33 10HmaX-0005vi-00 Completed diff --git a/test/log/5401 b/test/log/5401 new file mode 100644 index 000000000..6d38a372f --- /dev/null +++ b/test/log/5401 @@ -0,0 +1,3 @@ +1999-03-02 09:44:33 10HmaX-0005vi-00 >> userx@domain.com R=all T=smtp +1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss +1999-03-02 09:44:33 10HmaX-0005vi-00 Completed diff --git a/test/scripts/5400-cutthrough/5400 b/test/scripts/5400-cutthrough/5400 new file mode 100644 index 000000000..4aa332b86 --- /dev/null +++ b/test/scripts/5400-cutthrough/5400 @@ -0,0 +1,64 @@ +# cutthrough_delivery basic operation +need_ipv4 +# +server PORT_S +220 ESMTP +HELO +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +DATA +354 Send data +. +250 OK +QUIT +250 OK +**** +exim -d-all+acl+transport -bs +EHLO myhost.test.ex +MAIL FROM: +RCPT TO: +DATA + +. +QUIT +**** +# cutthrough cancelled by multiple recipients +server PORT_S 2 +220 ESMTP +HELO +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +QUIT +*eof +220 ESMTP +EHLO +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +RCPT TO: +250 Recipient OK +DATA +354 Send data +. +250 OK +QUIT +250 OK +**** +exim -d-all+acl+transport -bs +EHLO myhost.test.ex +MAIL FROM: +RCPT TO: +RCPT TO: +DATA + +. +QUIT +**** diff --git a/test/scripts/5400-cutthrough/5401 b/test/scripts/5400-cutthrough/5401 new file mode 100644 index 000000000..6104a7a7d --- /dev/null +++ b/test/scripts/5400-cutthrough/5401 @@ -0,0 +1,27 @@ +# cutthrough_delivery triggered by recipient-verify +need_ipv4 +# +server PORT_S +220 ESMTP +HELO +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +DATA +354 Send data +. +250 OK +QUIT +250 OK +**** +exim -d-all+acl+transport -bs +EHLO myhost.test.ex +MAIL FROM: +RCPT TO: +DATA + +. +QUIT +**** diff --git a/test/stderr/5400 b/test/stderr/5400 new file mode 100644 index 000000000..c8331e5da --- /dev/null +++ b/test/stderr/5400 @@ -0,0 +1,104 @@ +Exim version x.yz .... +configuration file is TESTSUITE/test-config +admin user +LOG: smtp_connection MAIN + SMTP connection from CALLER +processing "accept" +check control = cutthrough_delivery +accept: condition test succeeded in inline ACL +----------- start cutthrough setup ------------ +Connecting to 127.0.0.1 [127.0.0.1]:1224 from ip4.ip4.ip4.ip4 ... connected + SMTP<< 220 ESMTP + SMTP>> HELO myhost.test.ex + SMTP<< 250 OK + SMTP>> MAIL FROM: + SMTP<< 250 Sender OK + SMTP>> RCPT TO: + SMTP<< 250 Recipient OK +----------- end cutthrough setup ------------ +processing "accept" +accept: condition test succeeded in inline ACL + SMTP>> DATA + SMTP<< 354 Send data + SMTP>> . + SMTP<< 250 OK +----------- cutthrough close ------------ +LOG: MAIN + >> userx@domain.com R=all T=smtp +created log directory TESTSUITE/spool/log +LOG: MAIN + <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss +LOG: MAIN + Completed +LOG: smtp_connection MAIN + SMTP connection from CALLER closed by QUIT +>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>> +Exim version x.yz .... +configuration file is TESTSUITE/test-config +admin user +LOG: smtp_connection MAIN + SMTP connection from CALLER +processing "accept" +check control = cutthrough_delivery +accept: condition test succeeded in inline ACL +----------- start cutthrough setup ------------ +Connecting to 127.0.0.1 [127.0.0.1]:1224 from ip4.ip4.ip4.ip4 ... connected + SMTP<< 220 ESMTP + SMTP>> HELO myhost.test.ex + SMTP<< 250 OK + SMTP>> MAIL FROM: + SMTP<< 250 Sender OK + SMTP>> RCPT TO: + SMTP<< 250 Recipient OK +----------- end cutthrough setup ------------ +processing "accept" +check control = cutthrough_delivery +accept: condition test succeeded in inline ACL + SMTP>> QUIT +----------- cutthrough shutdown ------------ +LOG: MAIN + <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss +LOG: smtp_connection MAIN + SMTP connection from CALLER closed by QUIT +>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>> +Exim version x.yz .... +configuration file is TESTSUITE/test-config +trusted user +admin user +>>>>>>>>>>>>>>>> Remote deliveries >>>>>>>>>>>>>>>> +--------> userx@domain.com <-------- +smtp transport entered + userx@domain.com + usery@domain.com +checking status of 127.0.0.1 +127.0.0.1 [127.0.0.1]:1111 status = usable +delivering 10HmaY-0005vi-00 to 127.0.0.1 [127.0.0.1] (userx@domain.com, ...) +Connecting to 127.0.0.1 [127.0.0.1]:1224 from ip4.ip4.ip4.ip4 ... connected + SMTP<< 220 ESMTP + SMTP>> EHLO myhost.test.ex + SMTP<< 250 OK +not using PIPELINING + SMTP>> MAIL FROM: + SMTP<< 250 Sender OK + SMTP>> RCPT TO: + SMTP<< 250 Recipient OK + SMTP>> RCPT TO: + SMTP<< 250 Recipient OK + SMTP>> DATA + SMTP<< 354 Send data + SMTP>> writing message and terminating "." +writing data block fd=dddd size=sss timeout=300 + SMTP<< 250 OK +ok=1 send_quit=1 send_rset=0 continue_more=0 yield=0 first_address is NULL +transport_check_waiting entered + sequence=1 local_max=500 global_max=-1 +no messages waiting for 127.0.0.1 + SMTP>> QUIT +Leaving smtp transport +LOG: MAIN + => userx@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] +LOG: MAIN + -> usery@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] +LOG: MAIN + Completed +>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>> diff --git a/test/stderr/5401 b/test/stderr/5401 new file mode 100644 index 000000000..dc02c054f --- /dev/null +++ b/test/stderr/5401 @@ -0,0 +1,38 @@ +Exim version x.yz .... +configuration file is TESTSUITE/test-config +admin user +LOG: smtp_connection MAIN + SMTP connection from CALLER +using ACL "acl_rcpt" +processing "accept" +check control = cutthrough_delivery +check verify = recipient +----------- end verify ------------ +accept: condition test succeeded in ACL "acl_rcpt" +----------- start cutthrough setup ------------ +Connecting to 127.0.0.1 [127.0.0.1]:1224 from ip4.ip4.ip4.ip4 ... connected + SMTP<< 220 ESMTP + SMTP>> HELO myhost.test.ex + SMTP<< 250 OK + SMTP>> MAIL FROM: + SMTP<< 250 Sender OK + SMTP>> RCPT TO: + SMTP<< 250 Recipient OK +----------- end cutthrough setup ------------ +processing "accept" +accept: condition test succeeded in inline ACL + SMTP>> DATA + SMTP<< 354 Send data + SMTP>> . + SMTP<< 250 OK +----------- cutthrough close ------------ +LOG: MAIN + >> userx@domain.com R=all T=smtp +created log directory TESTSUITE/spool/log +LOG: MAIN + <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss +LOG: MAIN + Completed +LOG: smtp_connection MAIN + SMTP connection from CALLER closed by QUIT +>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>> diff --git a/test/stdout/5400 b/test/stdout/5400 new file mode 100644 index 000000000..a6c813be3 --- /dev/null +++ b/test/stdout/5400 @@ -0,0 +1,83 @@ +220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250-myhost.test.ex Hello CALLER at myhost.test.ex +250-SIZE 52428800 +250-PIPELINING +250 HELP +250 OK +250 Accepted +354 Enter message, ending with "." on a line by itself +250 OK id=10HmaX-0005vi-00 +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 myhost.test.ex +250-SIZE 52428800 +250-PIPELINING +250 HELP +250 OK +250 Accepted +250 Accepted +354 Enter message, ending with "." on a line by itself +250 OK id=10HmaY-0005vi-00 +221 myhost.test.ex closing connection + +******** SERVER ******** +Listening on port 1224 ... +Connection request from [ip4.ip4.ip4.ip4] +220 ESMTP +HELO myhost.test.ex +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +DATA +354 Send data +Received: from CALLER (helo=myhost.test.ex) + by myhost.test.ex with local-esmtp (Exim x.yz) + (envelope-from ) + id 10HmaX-0005vi-00 + for userx@domain.com; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +. +250 OK +Unexpected EOF read from client +Listening on port 1224 ... +Connection request from [ip4.ip4.ip4.ip4] +220 ESMTP +HELO myhost.test.ex +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +QUIT +Expected EOF read from client +Listening on port 1224 ... +Connection request from [ip4.ip4.ip4.ip4] +220 ESMTP +EHLO myhost.test.ex +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +RCPT TO: +250 Recipient OK +DATA +354 Send data +Received: from CALLER (helo=myhost.test.ex) + by myhost.test.ex with local-esmtp (Exim x.yz) + (envelope-from ) + id 10HmaY-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +. +250 OK +QUIT +250 OK +End of script diff --git a/test/stdout/5401 b/test/stdout/5401 new file mode 100644 index 000000000..79b7d73e2 --- /dev/null +++ b/test/stdout/5401 @@ -0,0 +1,35 @@ +220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250-myhost.test.ex Hello CALLER at myhost.test.ex +250-SIZE 52428800 +250-PIPELINING +250 HELP +250 OK +250 Accepted +354 Enter message, ending with "." on a line by itself +250 OK id=10HmaX-0005vi-00 +221 myhost.test.ex closing connection + +******** SERVER ******** +Listening on port 1224 ... +Connection request from [ip4.ip4.ip4.ip4] +220 ESMTP +HELO myhost.test.ex +250 OK +MAIL FROM: +250 Sender OK +RCPT TO: +250 Recipient OK +DATA +354 Send data +Received: from CALLER (helo=myhost.test.ex) + by myhost.test.ex with local-esmtp (Exim x.yz) + (envelope-from ) + id 10HmaX-0005vi-00 + for userx@domain.com; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +. +250 OK +Unexpected EOF read from client -- 2.30.2