From ce3258931d05becb2c87f17d80ee7c4b01f5a55a Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 17 Dec 2015 23:22:09 +0000 Subject: [PATCH] Fix hosts_connection_nolog ensuring that sender_host_cache is not incorrectly filled in by the daemon, where the sender_host will be varying. --- doc/doc-txt/ChangeLog | 3 +++ src/src/daemon.c | 1 + src/src/exim.c | 2 ++ src/src/smtp_in.c | 2 -- test/confs/0614 | 20 ++++++++++++++++++++ test/log/0614 | 3 +++ test/scripts/0000-Basic/0614 | 17 +++++++++++++++++ test/stdout/0614 | 10 ++++++++++ 8 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 test/confs/0614 create mode 100644 test/log/0614 create mode 100644 test/scripts/0000-Basic/0614 create mode 100644 test/stdout/0614 diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 884abc213..4622fbd36 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -131,6 +131,9 @@ JH/29 Move Events support from Experimental to mainline, enabled by default JH/30 Updated DANE implementation code to current from Viktor Dukhovni. +JH/31 Fix bug with hosts_connection_nolog and named-lists which were wrongly + cached by the daemon. + Exim version 4.86 ----------------- diff --git a/src/src/daemon.c b/src/src/daemon.c index 65195ccd1..24874c374 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -341,6 +341,7 @@ arrange to unset the selector in the subprocess. */ if (LOGGING(smtp_connection)) { uschar *list = hosts_connection_nolog; + memset(sender_host_cache, 0, sizeof(sender_host_cache)); if (list != NULL && verify_check_host(&list) == OK) save_log_selector &= ~L_smtp_connection; else diff --git a/src/src/exim.c b/src/src/exim.c index 9e4dafe2f..f8cfda8a8 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -5051,6 +5051,7 @@ if (host_checking) "**** This is not for real!\n\n", sender_host_address); + memset(sender_host_cache, 0, sizeof(sender_host_cache)); if (verify_check_host(&hosts_connection_nolog) == OK) BIT_CLEAR(log_selector, log_selector_size, Li_smtp_connection); log_write(L_smtp_connection, LOG_MAIN, "%s", smtp_get_connection_info()); @@ -5225,6 +5226,7 @@ if (smtp_input) { smtp_in = stdin; smtp_out = stdout; + memset(sender_host_cache, 0, sizeof(sender_host_cache)); if (verify_check_host(&hosts_connection_nolog) == OK) BIT_CLEAR(log_selector, log_selector_size, Li_smtp_connection); log_write(L_smtp_connection, LOG_MAIN, "%s", smtp_get_connection_info()); diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 3fce125d3..b48e436e3 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -1866,8 +1866,6 @@ pipelining_enable = TRUE; sync_cmd_limit = NON_SYNC_CMD_NON_PIPELINING; smtp_exit_function_called = FALSE; /* For avoiding loop in not-quit exit */ -memset(sender_host_cache, 0, sizeof(sender_host_cache)); - /* If receiving by -bs from a trusted user, or testing with -bh, we allow authentication settings from -oMaa to remain in force. */ diff --git a/test/confs/0614 b/test/confs/0614 new file mode 100644 index 000000000..2b2361747 --- /dev/null +++ b/test/confs/0614 @@ -0,0 +1,20 @@ +# Exim test configuration 0614 +# hosts_connection_nolog versus sender_host lists caching + +exim_path = EXIM_PATH +host_lookup_order = bydns +primary_hostname = myhost.test.ex +spool_directory = DIR/spool +log_file_path = DIR/spool/log/%slog +gecos_pattern = "" +gecos_name = CALLER_NAME +tls_advertise_hosts = + +# ----- Main settings ----- + +log_selector = +smtp_connection +hostlist nolog = 127.0.0.1 +hosts_connection_nolog = +nolog +queue_only + +# End diff --git a/test/log/0614 b/test/log/0614 new file mode 100644 index 000000000..f52733f62 --- /dev/null +++ b/test/log/0614 @@ -0,0 +1,3 @@ +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 SMTP connection from [ip4.ip4.ip4.ip4] (TCP/IP connection count = 1) +1999-03-02 09:44:33 SMTP connection from [ip4.ip4.ip4.ip4] closed by QUIT diff --git a/test/scripts/0000-Basic/0614 b/test/scripts/0000-Basic/0614 new file mode 100644 index 000000000..ff3931b16 --- /dev/null +++ b/test/scripts/0000-Basic/0614 @@ -0,0 +1,17 @@ +# hosts_connection_nolog versus sender_host lists caching +exim -bd -DSERVER=server -oX PORT_D +**** +# +# Will not log connection due to hosts_connection_nolog +client 127.0.0.1 PORT_D +??? 220 +QUIT +**** +# +# Connection should be logged +client HOSTIPV4 PORT_D +??? 220 +QUIT +**** +# +killdaemon diff --git a/test/stdout/0614 b/test/stdout/0614 new file mode 100644 index 000000000..f670e1e23 --- /dev/null +++ b/test/stdout/0614 @@ -0,0 +1,10 @@ +Connecting to 127.0.0.1 port 1225 ... connected +??? 220 +<<< 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +>>> QUIT +End of script +Connecting to ip4.ip4.ip4.ip4 port 1225 ... connected +??? 220 +<<< 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +>>> QUIT +End of script -- 2.30.2