Gitweb:
https://git.exim.org/exim.git/commitdiff/5990a26531db1a1ba1ed4bc04554ba217c910b45
Commit: 5990a26531db1a1ba1ed4bc04554ba217c910b45
Parent: 67ffc5f1b2a24add79f9eed82136ac3474b67b1e
Author: Jeremy Harris <jgh146exb@???>
AuthorDate: Sat May 16 16:36:08 2020 +0100
Committer: Jeremy Harris <jgh146exb@???>
CommitDate: Sat May 16 17:50:29 2020 +0100
Log additional command-history on too-many-syntax-errors
---
src/src/smtp_in.c | 54 +++++++++++++++++++++++++++++++++--------------------
test/log/0453 | 4 ++--
test/log/0566 | 2 +-
test/log/0901 | 2 +-
test/rejectlog/0453 | 4 ++--
test/rejectlog/0566 | 2 +-
test/rejectlog/0901 | 2 +-
test/stderr/0453 | 2 +-
8 files changed, 43 insertions(+), 29 deletions(-)
diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c
index 4c3d995..526164c 100644
--- a/src/src/smtp_in.c
+++ b/src/src/smtp_in.c
@@ -1816,6 +1816,29 @@ return g;
}
#endif
+
+
+static gstring *
+s_connhad_log(gstring * g)
+{
+uschar * sep = smtp_connection_had[SMTP_HBUFF_SIZE-1] != SCH_NONE
+ ? US" C=..." : US" C=";
+
+for (int i = smtp_ch_index; i < SMTP_HBUFF_SIZE; i++)
+ if (smtp_connection_had[i] != SCH_NONE)
+ {
+ g = string_append(g, 2, sep, smtp_names[smtp_connection_had[i]]);
+ sep = US",";
+ }
+for (int i = 0; i < smtp_ch_index; i++)
+ {
+ g = string_append(g, 2, sep, smtp_names[smtp_connection_had[i]]);
+ sep = US",";
+ }
+return g;
+}
+
+
/*************************************************
* Log lack of MAIL if so configured *
*************************************************/
@@ -1831,7 +1854,7 @@ Returns: nothing
void
smtp_log_no_mail(void)
{
-uschar * sep, * s;
+uschar * s;
gstring * g = NULL;
if (smtp_mailcmd_count > 0 || !LOGGING(smtp_no_mail))
@@ -1847,20 +1870,7 @@ if (sender_host_authenticated)
g = s_tlslog(g);
#endif
-sep = smtp_connection_had[SMTP_HBUFF_SIZE-1] != SCH_NONE ? US" C=..." : US" C=";
-
-for (int i = smtp_ch_index; i < SMTP_HBUFF_SIZE; i++)
- if (smtp_connection_had[i] != SCH_NONE)
- {
- g = string_append(g, 2, sep, smtp_names[smtp_connection_had[i]]);
- sep = US",";
- }
-
-for (int i = 0; i < smtp_ch_index; i++)
- {
- g = string_append(g, 2, sep, smtp_names[smtp_connection_had[i]]);
- sep = US",";
- }
+g = s_connhad_log(g);
if (!(s = string_from_gstring(g))) s = US"";
@@ -3102,15 +3112,17 @@ synprot_error(int type, int code, uschar *data, uschar *errmess)
int yield = -1;
log_write(type, LOG_MAIN, "SMTP %s error in \"%s\" %s %s",
- (type == L_smtp_syntax_error)? "syntax" : "protocol",
+ type == L_smtp_syntax_error ? "syntax" : "protocol",
string_printing(smtp_cmd_buffer), host_and_ident(TRUE), errmess);
if (++synprot_error_count > smtp_max_synprot_errors)
{
yield = 1;
log_write(0, LOG_MAIN|LOG_REJECT, "SMTP call from %s dropped: too many "
- "syntax or protocol errors (last command was \"%s\")",
- host_and_ident(FALSE), string_printing(smtp_cmd_buffer));
+ "syntax or protocol errors (last command was \"%s\", %s)",
+ host_and_ident(FALSE), string_printing(smtp_cmd_buffer),
+ string_from_gstring(s_connhad_log(NULL))
+ );
}
if (code > 0)
@@ -4158,8 +4170,10 @@ while (done <= 0)
if (++synprot_error_count > smtp_max_synprot_errors)
{
log_write(0, LOG_MAIN|LOG_REJECT, "SMTP call from %s dropped: too many "
- "syntax or protocol errors (last command was \"%s\")",
- host_and_ident(FALSE), string_printing(smtp_cmd_buffer));
+ "syntax or protocol errors (last command was \"%s\", %s)",
+ host_and_ident(FALSE), string_printing(smtp_cmd_buffer),
+ string_from_gstring(s_connhad_log(NULL))
+ );
done = 1;
}
diff --git a/test/log/0453 b/test/log/0453
index 5a2a891..4ca6114 100644
--- a/test/log/0453
+++ b/test/log/0453
@@ -2,5 +2,5 @@
1999-03-02 09:44:33 rejected HELO from CALLER: syntactically invalid argument(s): (no argument given)
1999-03-02 09:44:33 rejected HELO from CALLER: syntactically invalid argument(s): (no argument given)
1999-03-02 09:44:33 rejected HELO from CALLER: syntactically invalid argument(s): (no argument given)
-1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "helo")
-1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "mail from:<>")
+1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "helo", C=HELO,HELO,HELO,HELO)
+1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "mail from:<>", C=MAIL,MAIL,MAIL)
diff --git a/test/log/0566 b/test/log/0566
index 0922615..119b2d2 100644
--- a/test/log/0566
+++ b/test/log/0566
@@ -12,4 +12,4 @@
1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@??? U=CALLER P=local-esmtp S=sss M8S=8
1999-03-02 09:44:33 10HmaZ-0005vi-00 => userx <userx@???> R=r2 T=local_delivery
1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed
-1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "foo")
+1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "foo", C=EHLO,MAIL,RCPT,DATA)
diff --git a/test/log/0901 b/test/log/0901
index af07e73..e4bb6a2 100644
--- a/test/log/0901
+++ b/test/log/0901
@@ -11,5 +11,5 @@
1999-03-02 09:44:33 SMTP connection from (tester) [127.0.0.1] lost while reading message data
1999-03-02 09:44:33 10HmbD-0005vi-00 <= someone8@??? H=(tester) [127.0.0.1] P=esmtp K S=sss for CALLER@???
1999-03-02 09:44:33 SMTP protocol synchronization error (next input sent too soon: pipelining was not advertised): rejected "BDAT 1" H=(tester) [127.0.0.1] next input="BDAT 87 last\r\no: Susan@???"...
-1999-03-02 09:44:33 SMTP call from (tester) [127.0.0.1] dropped: too many syntax or protocol errors (last command was "From: Sam@???")
+1999-03-02 09:44:33 SMTP call from (tester) [127.0.0.1] dropped: too many syntax or protocol errors (last command was "From: Sam@???", C=EHLO,MAIL,RCPT,BDAT)
1999-03-02 09:44:33 SMTP connection from (tester) [127.0.0.1] lost while reading message data (header)
diff --git a/test/rejectlog/0453 b/test/rejectlog/0453
index 5a2a891..4ca6114 100644
--- a/test/rejectlog/0453
+++ b/test/rejectlog/0453
@@ -2,5 +2,5 @@
1999-03-02 09:44:33 rejected HELO from CALLER: syntactically invalid argument(s): (no argument given)
1999-03-02 09:44:33 rejected HELO from CALLER: syntactically invalid argument(s): (no argument given)
1999-03-02 09:44:33 rejected HELO from CALLER: syntactically invalid argument(s): (no argument given)
-1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "helo")
-1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "mail from:<>")
+1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "helo", C=HELO,HELO,HELO,HELO)
+1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "mail from:<>", C=MAIL,MAIL,MAIL)
diff --git a/test/rejectlog/0566 b/test/rejectlog/0566
index 7a420d0..bb4af83 100644
--- a/test/rejectlog/0566
+++ b/test/rejectlog/0566
@@ -1,3 +1,3 @@
1999-03-02 09:44:33 U=CALLER F=<x@y> rejected RCPT <userx@???>: SIZE value too big
1999-03-02 09:44:33 U=CALLER F=<x@y> rejected RCPT <userx@???>: SIZE value too big
-1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "foo")
+1999-03-02 09:44:33 SMTP call from CALLER dropped: too many syntax or protocol errors (last command was "foo", C=EHLO,MAIL,RCPT,DATA)
diff --git a/test/rejectlog/0901 b/test/rejectlog/0901
index a4185a9..79ecb96 100644
--- a/test/rejectlog/0901
+++ b/test/rejectlog/0901
@@ -3,6 +3,6 @@
1999-03-02 09:44:33 SMTP protocol synchronization error (next input sent too soon: pipelining was not advertised): rejected "BDAT 1" H=(tester) [127.0.0.1] next input="BDAT 87 last\r\no: Susan@???"...
Envelope-from: <someone9@???>
Envelope-to: <CALLER@???>
-1999-03-02 09:44:33 SMTP call from (tester) [127.0.0.1] dropped: too many syntax or protocol errors (last command was "From: Sam@???")
+1999-03-02 09:44:33 SMTP call from (tester) [127.0.0.1] dropped: too many syntax or protocol errors (last command was "From: Sam@???", C=EHLO,MAIL,RCPT,BDAT)
Envelope-from: <someone9@???>
Envelope-to: <CALLER@???>
diff --git a/test/stderr/0453 b/test/stderr/0453
index 1911c67..dee8339 100644
--- a/test/stderr/0453
+++ b/test/stderr/0453
@@ -7,4 +7,4 @@
>>> host in helo_try_verify_hosts? no (option unset)
>>> host in helo_accept_junk_hosts? no (option unset)
>>> xxxx in helo_lookup_domains? no (end of list)
-LOG: SMTP call from (xxxx) [V4NET.0.0.1] dropped: too many syntax or protocol errors (last command was "rcpt to:<bad syntax@???>")
+LOG: SMTP call from (xxxx) [V4NET.0.0.1] dropped: too many syntax or protocol errors (last command was "rcpt to:<bad syntax@???>", C=HELO,MAIL,RCPT,RCPT,RCPT,RCPT)