From: Philip Hazel Date: Mon, 20 Mar 2006 10:55:21 +0000 (+0000) Subject: Fix bounces for non-SMTP reception errors to recognize X-Git-Tag: exim-4_61~9 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/715ab37671cc2b25fe70463a940f2245af73615b Fix bounces for non-SMTP reception errors to recognize bounce_return_xxx. --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index ce3d142e7..4509b13e8 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.334 2006/03/17 16:51:45 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.335 2006/03/20 10:55:21 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -326,6 +326,14 @@ PH/66 Updated OS/Makefile-HP-UX for gcc 4.1.0 with HP-UX 11. PH/67 Fixed minor infelicity in the sorting of addresses to ensure that IPv6 is preferred over IPv4. +PH/68 The bounce_return_message and bounce_return_body options were not being + honoured for bounces generated during the reception of non-SMTP messages. + In particular, this applied to messages rejected by the ACL. This bug has + been fixed. However, if bounce_return_message is true and bounce_return_ + body is false, the headers that are returned for a non-SMTP message + include only those that have been read before the error was detected. + (In the case of an ACL rejection, they have all been read.) + Exim version 4.60 ----------------- diff --git a/src/src/moan.c b/src/src/moan.c index 63b3426bf..28046c2c5 100644 --- a/src/src/moan.c +++ b/src/src/moan.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/moan.c,v 1.5 2006/02/07 11:19:00 ph10 Exp $ */ +/* $Cambridge: exim/src/src/moan.c,v 1.6 2006/03/20 10:55:21 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -185,62 +185,74 @@ switch(ident) break; } -/* Now copy the message - headers then the rest of the input if -available, up to the configured limit. */ +/* Now, if configured, copy the message; first the headers and then the rest of +the input if available, up to the configured limit, if the option for including +message bodies in bounces is set. */ -if (size_limit == 0 || size_limit > thismessage_size_limit) - size_limit = thismessage_size_limit; - -if (size_limit > 0 && size_limit < message_size) +if (bounce_return_message) { - int x = size_limit; - uschar *k = US""; - if ((x & 1023) == 0) + if (bounce_return_body) { - k = US"K"; - x >>= 10; + fprintf(f, "\n" + "------ This is a copy of your message, including all the headers."); + if (size_limit == 0 || size_limit > thismessage_size_limit) + size_limit = thismessage_size_limit; + if (size_limit > 0 && size_limit < message_size) + { + int x = size_limit; + uschar *k = US""; + if ((x & 1023) == 0) + { + k = US"K"; + x >>= 10; + } + fprintf(f, "\n" + "------ No more than %d%s characters of the body are included.\n\n", + x, k); + } + else fprintf(f, " ------\n\n"); + } + else + { + fprintf(f, "\n" + "------ This is a copy of the headers that were received before the " + "error\n was detected.\n\n"); } - fprintf(f, "\n" - "------ This is a copy of your message, including all the headers.\n" - "------ No more than %d%s characters of the body are included.\n\n", x, k); - } -else fprintf(f, "\n" - "------ This is a copy of your message, including all the headers. ------" - "\n\n"); -/* If the error occurred before the Received: header was created, its text -field will still be NULL; just omit such a header line. */ + /* If the error occurred before the Received: header was created, its text + field will still be NULL; just omit such a header line. */ -while (headers != NULL) - { - if (headers->text != NULL) fprintf(f, "%s", CS headers->text); - headers = headers->next; - } + while (headers != NULL) + { + if (headers->text != NULL) fprintf(f, "%s", CS headers->text); + headers = headers->next; + } -if (ident != ERRMESS_VLONGHEADER && ident != ERRMESS_VLONGHDRLINE) - fputc('\n', f); + if (ident != ERRMESS_VLONGHEADER && ident != ERRMESS_VLONGHDRLINE) + fputc('\n', f); -/* After early detection of an error, the message file may be STDIN, -in which case we might have to terminate on a line containing just "." -as well as on EOF. We may already have the first line in memory. */ + /* After early detection of an error, the message file may be STDIN, + in which case we might have to terminate on a line containing just "." + as well as on EOF. We may already have the first line in memory. */ -if (message_file != NULL) - { - int ch; - int state = 1; - BOOL enddot = dot_ends && message_file == stdin; - if (firstline != NULL) fprintf(f, "%s", CS firstline); - while ((ch = fgetc(message_file)) != EOF) + if (bounce_return_body && message_file != NULL) { - fputc(ch, f); - if (size_limit > 0 && ++written > size_limit) break; - if (enddot) + int ch; + int state = 1; + BOOL enddot = dot_ends && message_file == stdin; + if (firstline != NULL) fprintf(f, "%s", CS firstline); + while ((ch = fgetc(message_file)) != EOF) { - if (state == 0) { if (ch == '\n') state = 1; } - else if (state == 1) - { if (ch == '.') state = 2; else if (ch != '\n') state = 0; } - else - { if (ch == '\n') break; else state = 0; } + fputc(ch, f); + if (size_limit > 0 && ++written > size_limit) break; + if (enddot) + { + if (state == 0) { if (ch == '\n') state = 1; } + else if (state == 1) + { if (ch == '.') state = 2; else if (ch != '\n') state = 0; } + else + { if (ch == '\n') break; else state = 0; } + } } } } diff --git a/src/src/version.c b/src/src/version.c index 351f476ea..42b5ae392 100644 --- a/src/src/version.c +++ b/src/src/version.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/version.c,v 1.13 2006/02/07 11:19:00 ph10 Exp $ */ +/* $Cambridge: exim/src/src/version.c,v 1.14 2006/03/20 10:55:21 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -12,7 +12,7 @@ #include "exim.h" -#define THIS_VERSION "4.61" +#define THIS_VERSION "4.61-RC1" /* The header file cnumber.h contains a single line containing the diff --git a/test/confs/0021 b/test/confs/0021 index 902d5f369..5ff787e28 100644 --- a/test/confs/0021 +++ b/test/confs/0021 @@ -1,6 +1,7 @@ # Exim test configuration 0021 SERVER= +BR= exim_path = EXIM_PATH host_lookup_order = bydns @@ -24,6 +25,8 @@ acl_smtp_helo = helo acl_smtp_mail = mail acl_smtp_rcpt = rcpt +BR + qualify_domain = test.ex trusted_users = CALLER diff --git a/test/log/0021 b/test/log/0021 index 5f6faf289..77ae6a64f 100644 --- a/test/log/0021 +++ b/test/log/0021 @@ -1,21 +1,21 @@ 1999-03-02 09:44:33 10HmaX-0005vi-00 F= rejected by non-SMTP ACL: don't like sender userx@test1 -1999-03-02 09:44:33 10HmbA-0005vi-00 <= <> R=10HmaX-0005vi-00 U=EXIMUSER P=local S=sss -1999-03-02 09:44:33 10HmbA-0005vi-00 => userx R=accept T=appendfile -1999-03-02 09:44:33 10HmbA-0005vi-00 Completed -1999-03-02 09:44:33 10HmbB-0005vi-00 <= ok@test1 U=CALLER P=local S=sss -1999-03-02 09:44:33 10HmbB-0005vi-00 => userx R=accept T=appendfile -1999-03-02 09:44:33 10HmbB-0005vi-00 Completed -1999-03-02 09:44:33 10HmaY-0005vi-00 F= rejected by non-SMTP ACL: cannot test hosts condition in non-SMTP ACL -1999-03-02 09:44:33 10HmbC-0005vi-00 <= <> R=10HmaY-0005vi-00 U=EXIMUSER P=local S=sss -1999-03-02 09:44:33 10HmbC-0005vi-00 => ok R=accept T=appendfile +1999-03-02 09:44:33 10HmbC-0005vi-00 <= <> R=10HmaX-0005vi-00 U=EXIMUSER P=local S=sss +1999-03-02 09:44:33 10HmbC-0005vi-00 => userx R=accept T=appendfile 1999-03-02 09:44:33 10HmbC-0005vi-00 Completed -1999-03-02 09:44:33 10HmbD-0005vi-00 <= ok@test3 U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmbD-0005vi-00 <= ok@test1 U=CALLER P=local S=sss 1999-03-02 09:44:33 10HmbD-0005vi-00 => userx R=accept T=appendfile 1999-03-02 09:44:33 10HmbD-0005vi-00 Completed -1999-03-02 09:44:33 10HmaZ-0005vi-00 F= rejected by non-SMTP ACL: no verified certificate -1999-03-02 09:44:33 10HmbE-0005vi-00 <= <> R=10HmaZ-0005vi-00 U=EXIMUSER P=local S=sss -1999-03-02 09:44:33 10HmbE-0005vi-00 => ok R=accept T=appendfile +1999-03-02 09:44:33 10HmaY-0005vi-00 F= rejected by non-SMTP ACL: cannot test hosts condition in non-SMTP ACL +1999-03-02 09:44:33 10HmbE-0005vi-00 <= <> R=10HmaY-0005vi-00 U=EXIMUSER P=local S=sss +1999-03-02 09:44:33 10HmbE-0005vi-00 => ok R=accept T=appendfile 1999-03-02 09:44:33 10HmbE-0005vi-00 Completed +1999-03-02 09:44:33 10HmbF-0005vi-00 <= ok@test3 U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmbF-0005vi-00 => userx R=accept T=appendfile +1999-03-02 09:44:33 10HmbF-0005vi-00 Completed +1999-03-02 09:44:33 10HmaZ-0005vi-00 F= rejected by non-SMTP ACL: no verified certificate +1999-03-02 09:44:33 10HmbG-0005vi-00 <= <> R=10HmaZ-0005vi-00 U=EXIMUSER P=local S=sss +1999-03-02 09:44:33 10HmbG-0005vi-00 => ok R=accept T=appendfile +1999-03-02 09:44:33 10HmbG-0005vi-00 Completed 1999-03-02 09:44:33 H=[10.9.8.7] U=CALLER rejected connection in "connect" ACL 1999-03-02 09:44:33 10.9.8.8 accepted by connect ACL 1999-03-02 09:44:33 H=[10.9.8.8] U=CALLER rejected MAIL @@ -28,6 +28,14 @@ 1999-03-02 09:44:33 H=(x.y.z) [10.9.8.10] U=CALLER rejected EHLO or HELO x.y.z 1999-03-02 09:44:33 10.9.8.8 accepted by connect ACL 1999-03-02 09:44:33 mail accepted -1999-03-02 09:44:33 10HmbF-0005vi-00 <= ok@test3 H=[10.9.8.8] U=CALLER P=smtp S=sss -1999-03-02 09:44:33 10HmbF-0005vi-00 => x R=accept T=appendfile -1999-03-02 09:44:33 10HmbF-0005vi-00 Completed +1999-03-02 09:44:33 10HmbH-0005vi-00 <= ok@test3 H=[10.9.8.8] U=CALLER P=smtp S=sss +1999-03-02 09:44:33 10HmbH-0005vi-00 => x R=accept T=appendfile +1999-03-02 09:44:33 10HmbH-0005vi-00 Completed +1999-03-02 09:44:33 10HmbA-0005vi-00 F= rejected by non-SMTP ACL: don't like sender userx@test1 +1999-03-02 09:44:33 10HmbI-0005vi-00 <= <> R=10HmbA-0005vi-00 U=EXIMUSER P=local S=sss +1999-03-02 09:44:33 10HmbI-0005vi-00 => userx R=accept T=appendfile +1999-03-02 09:44:33 10HmbI-0005vi-00 Completed +1999-03-02 09:44:33 10HmbB-0005vi-00 F= rejected by non-SMTP ACL: don't like sender userx@test1 +1999-03-02 09:44:33 10HmbJ-0005vi-00 <= <> R=10HmbB-0005vi-00 U=EXIMUSER P=local S=sss +1999-03-02 09:44:33 10HmbJ-0005vi-00 => userx R=accept T=appendfile +1999-03-02 09:44:33 10HmbJ-0005vi-00 Completed diff --git a/test/mail/0021.ok b/test/mail/0021.ok index c4e87e422..213d0c60a 100644 --- a/test/mail/0021.ok +++ b/test/mail/0021.ok @@ -1,12 +1,12 @@ From MAILER-DAEMON Tue Mar 02 09:44:33 1999 Received: from EXIMUSER by myhost.test.ex with local (Exim x.yz) - id 10HmbC-0005vi-00 + id 10HmbE-0005vi-00 for ok@test2; Tue, 2 Mar 1999 09:44:33 +0000 Auto-Submitted: auto-replied From: Mail Delivery System To: ok@test2 Subject: Mail failure - rejected by local scanning code -Message-Id: +Message-Id: Date: Tue, 2 Mar 1999 09:44:33 +0000 A message that you sent was rejected by the local scanning code that @@ -28,13 +28,13 @@ Test message 3. From MAILER-DAEMON Tue Mar 02 09:44:33 1999 Received: from EXIMUSER by myhost.test.ex with local (Exim x.yz) - id 10HmbE-0005vi-00 + id 10HmbG-0005vi-00 for ok@test4; Tue, 2 Mar 1999 09:44:33 +0000 Auto-Submitted: auto-replied From: Mail Delivery System To: ok@test4 Subject: Mail failure - rejected by local scanning code -Message-Id: +Message-Id: Date: Tue, 2 Mar 1999 09:44:33 +0000 A message that you sent was rejected by the local scanning code that diff --git a/test/mail/0021.userx b/test/mail/0021.userx index e8f147a4f..2abd8d315 100644 --- a/test/mail/0021.userx +++ b/test/mail/0021.userx @@ -1,12 +1,12 @@ From MAILER-DAEMON Tue Mar 02 09:44:33 1999 Received: from EXIMUSER by myhost.test.ex with local (Exim x.yz) - id 10HmbA-0005vi-00 + id 10HmbC-0005vi-00 for userx@test1; Tue, 2 Mar 1999 09:44:33 +0000 Auto-Submitted: auto-replied From: Mail Delivery System To: userx@test1 Subject: Mail failure - rejected by local scanning code -Message-Id: +Message-Id: Date: Tue, 2 Mar 1999 09:44:33 +0000 A message that you sent was rejected by the local scanning code that @@ -29,9 +29,9 @@ Test message 1. From ok@test1 Tue Mar 02 09:44:33 1999 Received: from CALLER by myhost.test.ex with local (Exim x.yz) (envelope-from ) - id 10HmbB-0005vi-00 + id 10HmbD-0005vi-00 for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 -Message-Id: +Message-Id: From: ok@test1 Date: Tue, 2 Mar 1999 09:44:33 +0000 @@ -40,11 +40,55 @@ Test message 2. From ok@test3 Tue Mar 02 09:44:33 1999 Received: from CALLER by myhost.test.ex with local (Exim x.yz) (envelope-from ) - id 10HmbD-0005vi-00 + id 10HmbF-0005vi-00 for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 -Message-Id: +Message-Id: From: ok@test3 Date: Tue, 2 Mar 1999 09:44:33 +0000 Test message 4. +From MAILER-DAEMON Tue Mar 02 09:44:33 1999 +Received: from EXIMUSER by myhost.test.ex with local (Exim x.yz) + id 10HmbI-0005vi-00 + for userx@test1; Tue, 2 Mar 1999 09:44:33 +0000 +Auto-Submitted: auto-replied +From: Mail Delivery System +To: userx@test1 +Subject: Mail failure - rejected by local scanning code +Message-Id: +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +A message that you sent was rejected by the local scanning code that +checks incoming messages on this system. The following error was given: + + don't like sender userx@test1 + +From MAILER-DAEMON Tue Mar 02 09:44:33 1999 +Received: from EXIMUSER by myhost.test.ex with local (Exim x.yz) + id 10HmbJ-0005vi-00 + for userx@test1; Tue, 2 Mar 1999 09:44:33 +0000 +Auto-Submitted: auto-replied +From: Mail Delivery System +To: userx@test1 +Subject: Mail failure - rejected by local scanning code +Message-Id: +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +A message that you sent was rejected by the local scanning code that +checks incoming messages on this system. The following error was given: + + don't like sender userx@test1 + +------ This is a copy of the headers that were received before the error + was detected. + +Received: from CALLER by myhost.test.ex with local (Exim x.yz) + (envelope-from ) + id 10HmbB-0005vi-00 + for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: userx@test1 +Date: Tue, 2 Mar 1999 09:44:33 +0000 + + diff --git a/test/mail/0021.x b/test/mail/0021.x index 41a8070f9..9dd43af38 100644 --- a/test/mail/0021.x +++ b/test/mail/0021.x @@ -2,7 +2,7 @@ From ok@test3 Tue Mar 02 09:44:33 1999 Received: from [10.9.8.8] (ident=CALLER) by myhost.test.ex with smtp (Exim x.yz) (envelope-from ) - id 10HmbF-0005vi-00 + id 10HmbH-0005vi-00 for x@y; Tue, 2 Mar 1999 09:44:33 +0000 X-ACL-Warn: added header line diff --git a/test/rejectlog/0021 b/test/rejectlog/0021 index 90e92c7c3..a2e943557 100644 --- a/test/rejectlog/0021 +++ b/test/rejectlog/0021 @@ -35,3 +35,23 @@ F From: ok@test4 1999-03-02 09:44:33 U=CALLER rejected connection in "connect" ACL 1999-03-02 09:44:33 H=(x.y.z) [10.9.8.10] U=CALLER rejected EHLO or HELO x.y.z 1999-03-02 09:44:33 mail accepted +1999-03-02 09:44:33 10HmbA-0005vi-00 F= rejected by non-SMTP ACL: don't like sender userx@test1 +Envelope-from: +Envelope-to: +P Received: from CALLER by myhost.test.ex with local (Exim x.yz) + (envelope-from ) + id 10HmbA-0005vi-00 + for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +I Message-Id: +F From: userx@test1 + Date: Tue, 2 Mar 1999 09:44:33 +0000 +1999-03-02 09:44:33 10HmbB-0005vi-00 F= rejected by non-SMTP ACL: don't like sender userx@test1 +Envelope-from: +Envelope-to: +P Received: from CALLER by myhost.test.ex with local (Exim x.yz) + (envelope-from ) + id 10HmbB-0005vi-00 + for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +I Message-Id: +F From: userx@test1 + Date: Tue, 2 Mar 1999 09:44:33 +0000 diff --git a/test/scripts/0000-Basic/0021 b/test/scripts/0000-Basic/0021 index 2ec354ffd..71b334130 100644 --- a/test/scripts/0000-Basic/0021 +++ b/test/scripts/0000-Basic/0021 @@ -48,3 +48,15 @@ Some message . quit **** +# Test unsetting bounce_return_message for non-SMTP +1 +exim -DBR=no_bounce_return_message -odi -f userx@test1 userx +Test message 1. +. +**** +# Test unsetting bounce_return_body for non-SMTP +1 +exim -DBR=no_bounce_return_body -odi -f userx@test1 userx +Test message 1. +. +**** diff --git a/test/stdout/0021 b/test/stdout/0021 index e09e72f1e..490d13fad 100644 --- a/test/stdout/0021 +++ b/test/stdout/0021 @@ -14,5 +14,5 @@ 250 OK 250 Accepted 354 Enter message, ending with "." on a line by itself -250 OK id=10HmbF-0005vi-00 +250 OK id=10HmbH-0005vi-00 221 myhost.test.ex closing connection