summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2016-09-10 21:37:56 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2016-09-11 16:13:03 +0100
commita57ce043b4c47bd069343100b602e14fad38c43c (patch)
tree1d4166dc0831816487762f51b39561f81e098241
parent59a286efa436395d340a4aba2bff35d611800bb5 (diff)
downloadexim4-a57ce043b4c47bd069343100b602e14fad38c43c.tar.gz
Log EHLO response on getting conn-close response for HELO. Bug 1832
-rw-r--r--doc/doc-txt/ChangeLog2
-rw-r--r--src/src/transports/smtp.c31
-rw-r--r--test/log/02114
-rw-r--r--test/scripts/0000-Basic/021116
-rw-r--r--test/scripts/5730-OCSP-GnuTLS-events/57304
-rw-r--r--test/stdout/02117
6 files changed, 60 insertions, 4 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index aeb67ecfa..40f06dc29 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -88,6 +88,8 @@ JH/23 Bug 1874: fix continued use of a connection for further deliveries.
(has no matching addresses), we lost track of needing to mark it
deferred. As a result mail would be lost.
+JH/24 Bug 1832: Log EHLO response on getting conn-close response for HELO.
+
Exim version 4.87
-----------------
diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c
index 677ce4ee1..85582e753 100644
--- a/src/src/transports/smtp.c
+++ b/src/src/transports/smtp.c
@@ -1525,6 +1525,7 @@ struct lflags {
BOOL send_quit:1;
BOOL setting_up:1;
BOOL esmtp:1;
+ BOOL esmtp_sent:1;
BOOL pending_MAIL:1;
#ifndef DISABLE_PRDR
BOOL prdr_active:1;
@@ -1572,6 +1573,7 @@ lflags.send_rset = TRUE;
lflags.send_quit = TRUE;
lflags.setting_up = TRUE;
lflags.esmtp = TRUE;
+lflags.esmtp_sent = FALSE;
lflags.pending_MAIL;
#ifndef DISABLE_PRDR
lflags.prdr_active;
@@ -1800,6 +1802,7 @@ goto SEND_QUIT;
if (smtp_write_command(&outblock, FALSE, "%s %s\r\n",
lflags.lmtp ? "LHLO" : "EHLO", helo_data) < 0)
goto SEND_FAILED;
+ lflags.esmtp_sent = TRUE;
if (!smtp_read_response(&inblock, buffer, sizeof(buffer), '2',
ob->command_timeout))
{
@@ -1823,15 +1826,37 @@ goto SEND_QUIT;
if (!lflags.esmtp)
{
BOOL good_response;
+ int n = sizeof(buffer);
+ uschar * rsp = buffer;
+
+ if (lflags.esmtp_sent && (n = Ustrlen(buffer)) < sizeof(buffer)/2)
+ { rsp = buffer + n + 1; n = sizeof(buffer) - n; }
if (smtp_write_command(&outblock, FALSE, "HELO %s\r\n", helo_data) < 0)
goto SEND_FAILED;
- good_response = smtp_read_response(&inblock, buffer, sizeof(buffer),
+ good_response = smtp_read_response(&inblock, rsp, n,
'2', ob->command_timeout);
#ifdef EXPERIMENTAL_DSN_INFO
- helo_response = string_copy(buffer);
+ helo_response = string_copy(rsp);
#endif
- if (!good_response) goto RESPONSE_FAILED;
+ if (!good_response)
+ {
+ /* Handle special logging for a closed connection after HELO
+ when had previously sent EHLO */
+
+ if (rsp != buffer && rsp[0] == 0 && (errno == 0 || errno == ECONNRESET))
+ {
+ message = NULL;
+ lflags.send_quit = FALSE;
+ save_errno = ERRNO_SMTPCLOSED;
+ message = string_sprintf("Remote host closed connection "
+ "in response to %s (EHLO response was: %s)",
+ smtp_command, buffer);
+ goto FAILED;
+ }
+ Ustrncpy(buffer, rsp, sizeof(buffer)/2);
+ goto RESPONSE_FAILED;
+ }
}
peer_offered = smtp_peer_options = 0;
diff --git a/test/log/0211 b/test/log/0211
index 9a5824674..cbf33c612 100644
--- a/test/log/0211
+++ b/test/log/0211
@@ -28,3 +28,7 @@
1999-03-02 09:44:33 10HmbA-0005vi-00 => CALLER <CALLER@test.ex> F=<> R=all T=local_delivery
1999-03-02 09:44:33 10HmbA-0005vi-00 Completed
1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed
+1999-03-02 09:44:33 Test: reject ehlo, then close (late, giving time for HELO)
+1999-03-02 09:44:33 10HmbB-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmbB-0005vi-00 H=localhost4.test.ex [127.0.0.1]: Remote host closed connection in response to HELO the.local.host.name (EHLO response was: 550 You are banned)
+1999-03-02 09:44:33 10HmbB-0005vi-00 == userx@domain1 R=others T=smtp defer (-18) H=localhost4.test.ex [127.0.0.1]: Remote host closed connection in response to HELO the.local.host.name (EHLO response was: 550 You are banned)
diff --git a/test/scripts/0000-Basic/0211 b/test/scripts/0000-Basic/0211
index f8750d2e8..dbe41c723 100644
--- a/test/scripts/0000-Basic/0211
+++ b/test/scripts/0000-Basic/0211
@@ -59,3 +59,19 @@ QUIT
exim -odi userx@domain1 usery@domain2
Test message 2
****
+#
+exim -z "Test: reject ehlo, then close (late, giving time for HELO)"
+****
+sudo rm DIR/spool/db/retry
+server PORT_S
+220 Connected OK
+EHLO
+550 You are banned
+HELO
+****
+exim -odi userx@domain1
+Test message 4
+****
+#
+#
+no_msglog_check
diff --git a/test/scripts/5730-OCSP-GnuTLS-events/5730 b/test/scripts/5730-OCSP-GnuTLS-events/5730
index b86b03264..d22a1aa1f 100644
--- a/test/scripts/5730-OCSP-GnuTLS-events/5730
+++ b/test/scripts/5730-OCSP-GnuTLS-events/5730
@@ -52,7 +52,7 @@ test message.
****
sleep 1
killdaemon
-no_msglog_check
+sudo rm DIR/spool/db/retry
#
#
#
@@ -65,6 +65,7 @@ test message.
****
sleep 1
killdaemon
+sudo rm DIR/spool/db/retry
#
#
#
@@ -82,3 +83,4 @@ killdaemon
#
#
#
+no_msglog_check
diff --git a/test/stdout/0211 b/test/stdout/0211
index ebe8246b0..93e271c6a 100644
--- a/test/stdout/0211
+++ b/test/stdout/0211
@@ -36,3 +36,10 @@ HELO the.local.host.name
QUIT
250 OK
End of script
+Listening on port 1224 ...
+Connection request from [127.0.0.1]
+220 Connected OK
+EHLO the.local.host.name
+550 You are banned
+HELO the.local.host.name
+End of script