From eea0defeafb2d80a0ce656518523c0e928df4933 Mon Sep 17 00:00:00 2001 From: Jasen Betts Date: Thu, 11 Aug 2016 23:31:57 +0100 Subject: [PATCH] ACL: Ensure that acl_smtp_notquit is called for a conndrop between data-go-ahead and data-ack. Bug 1872 --- doc/doc-txt/ChangeLog | 5 ++++- src/src/receive.c | 5 +++-- src/src/smtp_in.c | 15 +++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 60a4e4ea4..7304c9c04 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -71,7 +71,10 @@ JH/17 Fakereject: previously logged as a norml message arrival "<="; now JH/18 Bug 1867: make the fail_defer_domains option on a dnslookup router work for missing MX records. Previously it only worked for missing A records. -JH/19 Buf 1850: support Radius libraries that return REJECT_RC +JH/19 Bug 1850: support Radius libraries that return REJECT_RC. + +JH/20 Bug 1872: Ensure that acl_smtp_notquit is run when the connection drops + after the data-go-ahead and data-ack. Patch from Jason Betts. Exim version 4.87 diff --git a/src/src/receive.c b/src/src/receive.c index 3351ab1c5..4d30419f0 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -986,6 +986,7 @@ handle_lost_connection(uschar *s) { log_write(L_lost_incoming_connection | L_smtp_connection, LOG_MAIN, "%s lost while reading message data%s", smtp_get_connection_info(), s); +smtp_notquit_exit(US"connection-lost", NULL, NULL); return US"421 Lost incoming connection"; } @@ -4019,14 +4020,14 @@ if (smtp_input && sender_host_address != NULL && !sender_host_notsocket && int c = (receive_getc)(); if (c != EOF) (receive_ungetc)(c); else { - uschar *msg = US"SMTP connection lost after final dot"; + smtp_notquit_exit(US"connection-lost", NULL, NULL); smtp_reply = US""; /* No attempt to send a response */ smtp_yield = FALSE; /* Nothing more on this connection */ /* Re-use the log line workspace */ sptr = 0; - s = string_cat(s, &size, &sptr, msg); + s = string_cat(s, &size, &sptr, US"SMTP connection lost after final dot"); s = add_host_info_for_log(s, &size, &sptr); s[sptr] = 0; log_write(0, LOG_MAIN, "%s", s); diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 34481aef7..09356c231 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -3057,12 +3057,11 @@ smtp_exit_function_called = TRUE; /* Call the not-QUIT ACL, if there is one, unless no reason is given. */ -if (acl_smtp_notquit != NULL && reason != NULL) +if (acl_smtp_notquit && reason) { smtp_notquit_reason = reason; - rc = acl_check(ACL_WHERE_NOTQUIT, NULL, acl_smtp_notquit, &user_msg, - &log_msg); - if (rc == ERROR) + if ((rc = acl_check(ACL_WHERE_NOTQUIT, NULL, acl_smtp_notquit, &user_msg, + &log_msg)) == ERROR) log_write(0, LOG_MAIN|LOG_PANIC, "ACL for not-QUIT returned ERROR: %s", log_msg); } @@ -3072,9 +3071,11 @@ responses are all internal, they should always fit in the buffer, but code a warning, just in case. Note that string_vformat() still leaves a complete string, even if it is incomplete. */ -if (code != NULL && defaultrespond != NULL) +if (code && defaultrespond) { - if (user_msg == NULL) + if (user_msg) + smtp_respond(code, 3, TRUE, user_msg); + else { uschar buffer[128]; va_list ap; @@ -3084,8 +3085,6 @@ if (code != NULL && defaultrespond != NULL) smtp_printf("%s %s\r\n", code, buffer); va_end(ap); } - else - smtp_respond(code, 3, TRUE, user_msg); mac_smtp_fflush(); } } -- 2.25.1