From b9d9c5a27bea03802901872e0e056fb97b4c30a6 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Fri, 8 Apr 2016 19:37:13 +0100 Subject: [PATCH] Testsuite: 0322 (pipelining errors) avoid triggering SIGPIPE This was timing-dependent; if the exim closed the connection before the script wrote to it _after_ triggerring an error, EPIPE/SIGPIPE. Unexplained as yet: why runtest (perl) saw this as a 141 server returncode (NB: 141-128 = 13 = SIGPIPE, the shell behaviour) when "perldoc -v '$?'" (which runtest is coded to) says that a signum should be in the top nibble of 16b. --- src/src/transports/smtp.c | 1 + test/runtest | 1 + test/scripts/0000-Basic/0322 | 37 ++++++++---------------------------- test/src/server.c | 1 + test/stderr/0143 | 1 + test/stderr/0217 | 2 ++ test/stderr/0218 | 5 +++++ test/stderr/0276 | 2 ++ test/stderr/0388 | 1 + test/stderr/0467 | 1 + test/stderr/0476 | 1 + test/stderr/0525 | 1 + test/stderr/2008 | 3 +++ test/stderr/2013 | 2 ++ test/stderr/2108 | 3 +++ test/stderr/2113 | 2 ++ test/stderr/3404 | 3 +++ test/stdout/0322 | 27 +++++++++++++++----------- 18 files changed, 54 insertions(+), 40 deletions(-) diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 975fc16aa..6741c01a6 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -2958,6 +2958,7 @@ writing RSET might have failed, or there may be other addresses whose hosts are specified in the transports, and therefore not visible at top level, in which case continue_more won't get set. */ +HDEBUG(D_transport|D_acl|D_v) debug_printf(" SMTP(close)>>\n"); (void)close(inblock.sock); #ifndef DISABLE_EVENT diff --git a/test/runtest b/test/runtest index f6e57b4b5..fa38ca019 100755 --- a/test/runtest +++ b/test/runtest @@ -1977,6 +1977,7 @@ if (/^(ln|ls|du|mkdir|mkfifo|touch|cp|cat)\s/ || # command, triggered by $server_pid being non-zero. The server sends its output # to a different file. The variable $server_opts, if not empty, contains # options to disable IPv4 or IPv6 if necessary. +# This works because "server" swallows its stdin before waiting for a connection. if (/^server\s+(.*)$/) { diff --git a/test/scripts/0000-Basic/0322 b/test/scripts/0000-Basic/0322 index e317eb784..91fabeeb7 100644 --- a/test/scripts/0000-Basic/0322 +++ b/test/scripts/0000-Basic/0322 @@ -13,8 +13,7 @@ RCPT TO: 250 Recipient OK DATA > -QUIT -250 OK +*eof **** exim -odi x@test.ex **** @@ -29,9 +28,7 @@ MAIL FROM: RCPT TO: > DATA -550 Failed DATA -QUIT -250 OK +*eof **** exim -odi x@test.ex **** @@ -46,9 +43,7 @@ MAIL FROM: RCPT TO: 550 Can't send RCPT DATA -550 Can't send DATA -QUIT -250 OK +*eof **** exim -odi x@test.ex **** @@ -68,9 +63,7 @@ RCPT TO: RCPT TO: 250 Third RCPT OK DATA -550 Failed DATA -QUIT -250 OK +*eof **** exim -odi x@test.ex y@test.ex z@test.ex **** @@ -109,8 +102,7 @@ RCPT TO: 250 Recipient OK DATA > -QUIT -250 OK +*eof **** exim -odi x@test.ex **** @@ -123,10 +115,7 @@ MAIL FROM: 250 Sender OK RCPT TO: > -DATA -550 Failed DATA -QUIT -250 OK +*eof **** exim -odi x@test.ex **** @@ -137,12 +126,7 @@ EHLO 250 HELP MAIL FROM: > -RCPT TO: -550 Can't send RCPT -DATA -550 Can't send DATA -QUIT -250 OK +*eof **** exim -odi x@test.ex **** @@ -158,12 +142,7 @@ RCPT TO: RCPT TO: > 250 Second RCPT malformed -RCPT TO: -250 Third RCPT OK -DATA -550 Failed DATA -QUIT -250 OK +*eof **** exim -odi x@test.ex y@test.ex z@test.ex **** diff --git a/test/src/server.c b/test/src/server.c index 3aecf76f0..4f2172376 100644 --- a/test/src/server.c +++ b/test/src/server.c @@ -572,6 +572,7 @@ for (count = 0; count < connection_count; count++) cr.pid, cr.uid, cr.gid); --------------*****************/ } + fflush(stdout); if (dup_accept_socket < 0) { diff --git a/test/stderr/0143 b/test/stderr/0143 index 4be0d5227..e0fe9dc93 100644 --- a/test/stderr/0143 +++ b/test/stderr/0143 @@ -39,6 +39,7 @@ transport_check_waiting entered sequence=1 local_max=500 global_max=-1 no messages waiting for 127.0.0.1 SMTP>> QUIT + SMTP(close)>> Leaving my_smtp transport LOG: MAIN => userx@domain.com R=my_main_router T=my_smtp H=127.0.0.1 [127.0.0.1] C="250 OK" diff --git a/test/stderr/0217 b/test/stderr/0217 index 259df4604..9e31fb1d0 100644 --- a/test/stderr/0217 +++ b/test/stderr/0217 @@ -413,6 +413,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP<< 550 NO SMTP<< 403 Sorry temp data error SMTP>> QUIT + SMTP(close)>> LOG: MAIN == yes@test.ex R=client T=send_to_server defer (-46) H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined DATA: 403 Sorry temp data error LOG: MAIN @@ -847,6 +848,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP>> writing message and terminating "." SMTP<< 250 OK SMTP>> QUIT + SMTP(close)>> LOG: MAIN => w@test.ex R=client T=send_to_server H=127.0.0.1 [127.0.0.1] C="250 OK" LOG: MAIN diff --git a/test/stderr/0218 b/test/stderr/0218 index 4c74ff294..c58c83011 100644 --- a/test/stderr/0218 +++ b/test/stderr/0218 @@ -28,6 +28,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP<< 351 Send more SMTP>> writing message and terminating "." SMTP<< 250 OK + SMTP(close)>> LOG: MAIN => a@test.ex F= R=client T=send_to_server H=127.0.0.1 [127.0.0.1] C="250 OK" LOG: MAIN @@ -48,6 +49,7 @@ T: send_to_server (ACL) SMTP>> writing message and terminating "." SMTP<< 250 OK SMTP>> QUIT + SMTP(close)>> LOG: MAIN => b@test.ex F= R=client T=send_to_server H=127.0.0.1 [127.0.0.1]* C="250 OK" LOG: MAIN @@ -85,6 +87,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP<< 503 Unexpected RCPT SMTP<< 503 Unexpected DATA SMTP>> QUIT + SMTP(close)>> LOG: MAIN ** a@test.ex F= R=client T=send_to_server H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after MAIL FROM:: 550 NO Exim version x.yz .... @@ -142,6 +145,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP<< 503 Unexpected DATA SMTP>> RSET SMTP<< 250 OK + SMTP(close)>> LOG: MAIN ** b@test.ex F= R=client T=send_to_server H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after RCPT TO:: 550 Unknown Exim version x.yz .... @@ -169,6 +173,7 @@ T: send_to_server (ACL) SMTP>> writing message and terminating "." SMTP<< 250 OK SMTP>> QUIT + SMTP(close)>> LOG: MAIN => c@test.ex F= R=client T=send_to_server H=127.0.0.1 [127.0.0.1]* C="250 OK" LOG: MAIN diff --git a/test/stderr/0276 b/test/stderr/0276 index 2b01713f8..030801927 100644 --- a/test/stderr/0276 +++ b/test/stderr/0276 @@ -14,6 +14,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP<< 250 OK SMTP<< 500 NO SMTP>> QUIT + SMTP(close)>> LOG: MAIN ** userx@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after pipelined DATA: 500 NO LOG: MAIN @@ -47,6 +48,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP>> DATA SMTP<< 500 NO SMTP>> QUIT + SMTP(close)>> LOG: MAIN ** userx@test.ex R=r1 T=t1 H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after DATA: 500 NO LOG: MAIN diff --git a/test/stderr/0388 b/test/stderr/0388 index 5f4680130..67b47ab06 100644 --- a/test/stderr/0388 +++ b/test/stderr/0388 @@ -95,6 +95,7 @@ LOG: MAIN H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after RCPT TO:: 451 Temporary error added retry item for R:x@y: errno=-44 more_errno=dd,A flags=0 SMTP>> QUIT + SMTP(close)>> set_process_info: pppp delivering 10HmaX-0005vi-00: just tried 127.0.0.1 [127.0.0.1] for x@y: result OK address match test: subject=*@127.0.0.1 pattern=* 127.0.0.1 in "*"? yes (matched "*") diff --git a/test/stderr/0467 b/test/stderr/0467 index ec84ba9c0..8d2018ee7 100644 --- a/test/stderr/0467 +++ b/test/stderr/0467 @@ -30,6 +30,7 @@ Connecting to localhost.test.ex [127.0.0.1]:1224 ... connected SMTP>> writing message and terminating "." SMTP<< 250 OK SMTP>> QUIT + SMTP(close)>> LOG: MAIN => x@srv27.test.ex R=r1 T=t1 H=localhost.test.ex [127.0.0.1]:1224 C="250 OK" LOG: MAIN diff --git a/test/stderr/0476 b/test/stderr/0476 index eaebb34d4..29b9c3ebb 100644 --- a/test/stderr/0476 +++ b/test/stderr/0476 @@ -36,6 +36,7 @@ transport_check_waiting entered sequence=1 local_max=500 global_max=-1 SMTP>> RSET H=127.0.0.1 [127.0.0.1] Remote host closed connection in response to RSET + SMTP(close)>> set_process_info: pppp delivering 10HmaX-0005vi-00: just tried 127.0.0.1 [127.0.0.1] for userx@test.ex: result OK Leaving t1 transport set_process_info: pppp delivering 10HmaX-0005vi-00 (just run t1 for userx@test.ex in subprocess) diff --git a/test/stderr/0525 b/test/stderr/0525 index 553f8c1ce..a15308559 100644 --- a/test/stderr/0525 +++ b/test/stderr/0525 @@ -14,6 +14,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP>> DATA SMTP<< 354 SEND SMTP>> writing message and terminating "." + SMTP(close)>> LOG: MAIN H=127.0.0.1 [127.0.0.1]: SMTP timeout after sending data block (ddd bytes written): Connection timed out LOG: MAIN diff --git a/test/stderr/2008 b/test/stderr/2008 index cfd510557..dd4abbe40 100644 --- a/test/stderr/2008 +++ b/test/stderr/2008 @@ -27,6 +27,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1225 ... connected SMTP>> writing message and terminating "." SMTP<< 250 OK id=10HmaZ-0005vi-00 SMTP>> QUIT + SMTP(close)>> LOG: MAIN => CALLER@test.ex R=client T=send_to_server1 H=127.0.0.1 [127.0.0.1] X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 CV=no DN="C=UK,O=The Exim Maintainers,OU=Test Suite,CN=Phil Pennock" C="250 OK id=10HmaZ-0005vi-00" LOG: MAIN @@ -60,6 +61,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1225 ... connected SMTP>> writing message and terminating "." SMTP<< 250 OK id=10HmbA-0005vi-00 SMTP>> QUIT + SMTP(close)>> LOG: MAIN => CALLER@test.ex R=client T=send_to_server1 H=127.0.0.1 [127.0.0.1] X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 CV=no DN="C=UK,O=The Exim Maintainers,OU=Test Suite,CN=Phil Pennock" C="250 OK id=10HmbA-0005vi-00" LOG: MAIN @@ -90,6 +92,7 @@ Connecting to ip4.ip4.ip4.ip4 [ip4.ip4.ip4.ip4]:1225 ... connected SMTP>> writing message and terminating "." SMTP<< 250 OK id=10HmbB-0005vi-00 SMTP>> QUIT + SMTP(close)>> LOG: MAIN => abcd@test.ex R=client T=send_to_server2 H=ip4.ip4.ip4.ip4 [ip4.ip4.ip4.ip4] X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 CV=no DN="C=UK,O=The Exim Maintainers,OU=Test Suite,CN=Phil Pennock" C="250 OK id=10HmbB-0005vi-00" LOG: MAIN diff --git a/test/stderr/2013 b/test/stderr/2013 index 58d52d2f5..11e165c61 100644 --- a/test/stderr/2013 +++ b/test/stderr/2013 @@ -34,6 +34,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1225 ... connected 250-PIPELINING 250-STARTTLS 250 HELP + SMTP(close)>> LOG: MAIN => userx@test.ex R=client T=send_to_server H=127.0.0.1 [127.0.0.1] X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 CV=no DN="C=UK,O=The Exim Maintainers,OU=Test Suite,CN=Phil Pennock" C="250 OK id=10HmaZ-0005vi-00" LOG: MAIN @@ -58,6 +59,7 @@ admin user SMTP<< 354 Enter message, ending with "." on a line by itself SMTP<< 250 OK id=10HmbA-0005vi-00 SMTP>> QUIT + SMTP(close)>> LOG: MAIN => userx@test.ex R=client T=send_to_server H=127.0.0.1 [127.0.0.1]* X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 CV=no DN="C=UK,O=The Exim Maintainers,OU=Test Suite,CN=Phil Pennock" C="250 OK id=10HmbA-0005vi-00" LOG: MAIN diff --git a/test/stderr/2108 b/test/stderr/2108 index df110cc5a..1a9bb89c2 100644 --- a/test/stderr/2108 +++ b/test/stderr/2108 @@ -31,6 +31,7 @@ LOG: MAIN SMTP>> writing message and terminating "." SMTP<< 250 OK id=10HmaZ-0005vi-00 SMTP>> QUIT + SMTP(close)>> LOG: MAIN => CALLER@test.ex R=client T=send_to_server1 H=127.0.0.1 [127.0.0.1] X=TLSv1:AES256-SHA:256 CV=no DN="/C=UK/O=The Exim Maintainers/OU=Test Suite/CN=Phil Pennock" C="250 OK id=10HmaZ-0005vi-00" LOG: MAIN @@ -68,6 +69,7 @@ LOG: MAIN SMTP>> writing message and terminating "." SMTP<< 250 OK id=10HmbA-0005vi-00 SMTP>> QUIT + SMTP(close)>> LOG: MAIN => CALLER@test.ex R=client T=send_to_server1 H=127.0.0.1 [127.0.0.1] X=TLSv1:AES256-SHA:256 CV=no DN="/C=UK/O=The Exim Maintainers/OU=Test Suite/CN=Phil Pennock" C="250 OK id=10HmbA-0005vi-00" LOG: MAIN @@ -102,6 +104,7 @@ LOG: MAIN SMTP>> writing message and terminating "." SMTP<< 250 OK id=10HmbB-0005vi-00 SMTP>> QUIT + SMTP(close)>> LOG: MAIN => abcd@test.ex R=client T=send_to_server2 H=ip4.ip4.ip4.ip4 [ip4.ip4.ip4.ip4] X=TLSv1:AES256-SHA:256 CV=no DN="/C=UK/O=The Exim Maintainers/OU=Test Suite/CN=Phil Pennock" C="250 OK id=10HmbB-0005vi-00" LOG: MAIN diff --git a/test/stderr/2113 b/test/stderr/2113 index 3efab7e3a..ec5e415c6 100644 --- a/test/stderr/2113 +++ b/test/stderr/2113 @@ -34,6 +34,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1225 ... connected 250-PIPELINING 250-STARTTLS 250 HELP + SMTP(close)>> LOG: MAIN => userx@test.ex R=client T=send_to_server H=127.0.0.1 [127.0.0.1] X=TLSv1:AES256-SHA:256 CV=no DN="/C=UK/O=The Exim Maintainers/OU=Test Suite/CN=Phil Pennock" C="250 OK id=10HmaZ-0005vi-00" LOG: MAIN @@ -58,6 +59,7 @@ admin user SMTP<< 354 Enter message, ending with "." on a line by itself SMTP<< 250 OK id=10HmbA-0005vi-00 SMTP>> QUIT + SMTP(close)>> LOG: MAIN => userx@test.ex R=client T=send_to_server H=127.0.0.1 [127.0.0.1]* X=TLSv1:AES256-SHA:256 CV=no DN="/C=UK/O=The Exim Maintainers/OU=Test Suite/CN=Phil Pennock" C="250 OK id=10HmbA-0005vi-00" LOG: MAIN diff --git a/test/stderr/3404 b/test/stderr/3404 index 8d35b6730..361f9fd82 100644 --- a/test/stderr/3404 +++ b/test/stderr/3404 @@ -18,6 +18,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP>> writing message and terminating "." SMTP<< 250 OK SMTP>> QUIT + SMTP(close)>> LOG: MAIN => userx@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] A=plain C="250 OK" LOG: MAIN @@ -42,6 +43,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP>> writing message and terminating "." SMTP<< 250 OK SMTP>> QUIT + SMTP(close)>> LOG: MAIN => userx@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] A=plain C="250 OK" LOG: MAIN @@ -70,6 +72,7 @@ Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected SMTP>> writing message and terminating "." SMTP<< 250 OK SMTP>> QUIT + SMTP(close)>> LOG: MAIN => userx@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] A=login C="250 OK" LOG: MAIN diff --git a/test/stdout/0322 b/test/stdout/0322 index 7bf7be255..01894f128 100644 --- a/test/stdout/0322 +++ b/test/stdout/0322 @@ -13,7 +13,8 @@ RCPT TO: 250 Recipient OK DATA > -Unexpected EOF read from client +Expected EOF read from client +End of script Listening on port 1224 ... Connection request from [127.0.0.1] 220 ESMTP @@ -26,8 +27,8 @@ MAIL FROM: RCPT TO: > DATA -550 Failed DATA -Unexpected EOF read from client +Expected EOF read from client +End of script Listening on port 1224 ... Connection request from [127.0.0.1] 220 ESMTP @@ -40,8 +41,8 @@ MAIL FROM: RCPT TO: 550 Can't send RCPT DATA -550 Can't send DATA -Unexpected EOF read from client +Expected EOF read from client +End of script Listening on port 1224 ... Connection request from [127.0.0.1] 220 ESMTP @@ -59,8 +60,8 @@ RCPT TO: RCPT TO: 250 Third RCPT OK DATA -550 Failed DATA -Unexpected EOF read from client +Expected EOF read from client +End of script Listening on port 1224 ... Connection request from [127.0.0.1] 220 ESMTP @@ -91,7 +92,8 @@ RCPT TO: 250 Recipient OK DATA > -Unexpected EOF read from client +Expected EOF read from client +End of script Listening on port 1224 ... Connection request from [127.0.0.1] 220 ESMTP @@ -102,7 +104,8 @@ MAIL FROM: 250 Sender OK RCPT TO: > -Unexpected EOF read from client +Expected EOF read from client +End of script Listening on port 1224 ... Connection request from [127.0.0.1] 220 ESMTP @@ -111,7 +114,8 @@ EHLO myhost.test.ex 250 HELP MAIL FROM: > -Unexpected EOF read from client +Expected EOF read from client +End of script Listening on port 1224 ... Connection request from [127.0.0.1] 220 ESMTP @@ -125,4 +129,5 @@ RCPT TO: RCPT TO: > 250 Second RCPT malformed -Unexpected EOF read from client +Expected EOF read from client +End of script -- 2.25.1