From f41bc530a8b1a66e811e5c3b4da3df72ecba0e1d Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Wed, 26 Jun 2019 11:17:52 +0100 Subject: [PATCH] Fix DSN Final-Recipient: field (cherry picked from commits 436bda2ac0c4 and 98d4eb7a84) (cherry picked from commit 6b88f51ac13b4fa834796ce12d12c55c95eacc4a) (cherry picked from commit ce4d8eca9d3940bb439cdb74a250090fee5538d4) --- doc/doc-txt/ChangeLog | 5 +++++ src/src/deliver.c | 39 +++++++++++++++++++++++++-------------- test/mail/0015.CALLER | 4 ++-- test/mail/0037.CALLER | 4 ++-- test/mail/0048.CALLER | 10 +++++----- test/mail/0098.CALLER | 6 +++--- test/mail/0103.CALLER | 2 +- test/mail/0136.forwarder | 4 ++-- test/mail/0164.CALLER | 4 ++-- test/mail/0165.CALLER | 4 ++-- test/mail/0224.CALLER | 10 +++++----- test/mail/0226.CALLER | 6 +++--- test/mail/0237.CALLER | 6 +++--- test/mail/0383.CALLER | 6 +++--- test/mail/0428.CALLER | 4 ++-- test/mail/0508.postmaster | 2 +- 16 files changed, 66 insertions(+), 50 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 67dfafa7a..3b36c87b9 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -82,6 +82,11 @@ JH/27 Bug 2404: Use the main-section configuration option "dsn_from" for PP/01 Unbreak heimdal_gssapi, broken in 4.92. +JH/29 Fix DSN Final-Recipient: field. Previously it was the post-routing + delivery address, which leaked information of the results of local + forwarding. Change to the original envelope recipient address, per + standards. + Exim version 4.92 ----------------- diff --git a/src/src/deliver.c b/src/src/deliver.c index 4720f596a..53562dd5c 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -5507,6 +5507,25 @@ while ((addr = *anchor)) +/************************************************/ + +static void +print_dsn_addr_action(FILE * f, address_item * addr, + uschar * action, uschar * status) +{ +address_item * pa; + +if (addr->dsn_orcpt) + fprintf(f,"Original-Recipient: %s\n", addr->dsn_orcpt); + +for (pa = addr; pa->parent; ) pa = pa->parent; +fprintf(f, "Action: %s\n" + "Final-Recipient: rfc822;%s\n" + "Status: %s\n", + action, pa->address, status); +} + + /************************************************* * Deliver one message * *************************************************/ @@ -7410,10 +7429,7 @@ if (addr_senddsn) if (addr_dsntmp->dsn_orcpt) fprintf(f,"Original-Recipient: %s\n", addr_dsntmp->dsn_orcpt); - fprintf(f, "Action: delivered\n" - "Final-Recipient: rfc822;%s\n" - "Status: 2.0.0\n", - addr_dsntmp->address); + print_dsn_addr_action(f, addr_dsntmp, US"delivered", US"2.0.0"); if (addr_dsntmp->host_used && addr_dsntmp->host_used->name) fprintf(f, "Remote-MTA: dns; %s\nDiagnostic-Code: smtp; 250 Ok\n\n", @@ -7798,10 +7814,9 @@ wording. */ for (addr = handled_addr; addr; addr = addr->next) { host_item * hu; - fprintf(fp, "Action: failed\n" - "Final-Recipient: rfc822;%s\n" - "Status: 5.0.0\n", - addr->address); + + print_dsn_addr_action(fp, addr, US"failed", US"5.0.0"); + if ((hu = addr->host_used) && hu->name) { fprintf(fp, "Remote-MTA: dns; %s\n", hu->name); @@ -8343,13 +8358,9 @@ else if (addr_defer != (address_item *)(+1)) for ( ; addr_dsndefer; addr_dsndefer = addr_dsndefer->next) { - if (addr_dsndefer->dsn_orcpt) - fprintf(f, "Original-Recipient: %s\n", addr_dsndefer->dsn_orcpt); - fprintf(f, "Action: delayed\n" - "Final-Recipient: rfc822;%s\n" - "Status: 4.0.0\n", - addr_dsndefer->address); + print_dsn_addr_action(f, addr_dsndefer, US"delayed", US"4.0.0"); + if (addr_dsndefer->host_used && addr_dsndefer->host_used->name) { fprintf(f, "Remote-MTA: dns; %s\n", diff --git a/test/mail/0015.CALLER b/test/mail/0015.CALLER index 01ec97713..f251d9711 100644 --- a/test/mail/0015.CALLER +++ b/test/mail/0015.CALLER @@ -34,7 +34,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|callpager +Final-Recipient: rfc822;page+userx@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -90,7 +90,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|callpager +Final-Recipient: rfc822;page+ux@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0037.CALLER b/test/mail/0037.CALLER index 4ba7eef27..1985986ea 100644 --- a/test/mail/0037.CALLER +++ b/test/mail/0037.CALLER @@ -118,7 +118,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|cat +Final-Recipient: rfc822;filter-pipe@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -172,7 +172,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;/tmp/junk +Final-Recipient: rfc822;filter-file@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0048.CALLER b/test/mail/0048.CALLER index 5df13656b..fc1201e10 100644 --- a/test/mail/0048.CALLER +++ b/test/mail/0048.CALLER @@ -76,7 +76,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv +Final-Recipient: rfc822;pipe@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -173,7 +173,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv +Final-Recipient: rfc822;prefixed+pipe@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -270,7 +270,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv +Final-Recipient: rfc822;pipe-suffixed@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -367,7 +367,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv +Final-Recipient: rfc822;prefixed+pipe-suffixed@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -464,7 +464,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv +Final-Recipient: rfc822;pipe@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0098.CALLER b/test/mail/0098.CALLER index 722955ecf..2f83f9116 100644 --- a/test/mail/0098.CALLER +++ b/test/mail/0098.CALLER @@ -42,7 +42,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: delayed -Final-Recipient: rfc822;|/non/existing/file +Final-Recipient: rfc822;userx@test.ex Status: 4.0.0 Action: delayed @@ -172,7 +172,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: delayed -Final-Recipient: rfc822;|/non/existing/file +Final-Recipient: rfc822;userx@test.ex Status: 4.0.0 Action: delayed @@ -232,7 +232,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: delayed -Final-Recipient: rfc822;|/non/existing/file +Final-Recipient: rfc822;userx@test.ex Status: 4.0.0 Action: delayed diff --git a/test/mail/0103.CALLER b/test/mail/0103.CALLER index 64ca04d47..5461909ff 100644 --- a/test/mail/0103.CALLER +++ b/test/mail/0103.CALLER @@ -30,7 +30,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;WASabc@x.y.zWAS +Final-Recipient: rfc822;"abc@x.y.z"@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0136.forwarder b/test/mail/0136.forwarder index 1aa46d600..511ecab32 100644 --- a/test/mail/0136.forwarder +++ b/test/mail/0136.forwarder @@ -34,7 +34,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;unknown@test.ex +Final-Recipient: rfc822;forwarder@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -88,7 +88,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;unknown@test.ex +Final-Recipient: rfc822;forwarder@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0164.CALLER b/test/mail/0164.CALLER index 3a1b3d13e..dbc44d510 100644 --- a/test/mail/0164.CALLER +++ b/test/mail/0164.CALLER @@ -73,7 +73,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv $recipients +Final-Recipient: rfc822;system-filter Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -165,7 +165,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv $recipients +Final-Recipient: rfc822;system-filter Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0165.CALLER b/test/mail/0165.CALLER index 0c1cd6817..30f63c990 100644 --- a/test/mail/0165.CALLER +++ b/test/mail/0165.CALLER @@ -73,7 +73,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv $recipients +Final-Recipient: rfc822;system-filter Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -167,7 +167,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv $recipients +Final-Recipient: rfc822;system-filter Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0224.CALLER b/test/mail/0224.CALLER index b05090732..090003e8e 100644 --- a/test/mail/0224.CALLER +++ b/test/mail/0224.CALLER @@ -35,11 +35,11 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;hbounce@test.ex +Final-Recipient: rfc822;useryx@test.ex Status: 5.0.0 Action: failed -Final-Recipient: rfc822;bounce@test.ex +Final-Recipient: rfc822;userxx@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -105,15 +105,15 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: delayed -Final-Recipient: rfc822;/no/such/file +Final-Recipient: rfc822;file@test.ex Status: 4.0.0 Action: delayed -Final-Recipient: rfc822;defer@test.ex +Final-Recipient: rfc822;userxy@test.ex Status: 4.0.0 Action: delayed -Final-Recipient: rfc822;hdefer@test.ex +Final-Recipient: rfc822;useryy@test.ex Status: 4.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0226.CALLER b/test/mail/0226.CALLER index 6fdc064f2..0b5653691 100644 --- a/test/mail/0226.CALLER +++ b/test/mail/0226.CALLER @@ -32,11 +32,11 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;/a/b/c +Final-Recipient: rfc822;/a/b/c@no.test.ex Status: 5.0.0 Action: failed -Final-Recipient: rfc822;|/p/q/r +Final-Recipient: rfc822;|/p/q/r@no.test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -128,7 +128,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv +Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv@yes.test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0237.CALLER b/test/mail/0237.CALLER index 2fa164320..9bd9e578c 100644 --- a/test/mail/0237.CALLER +++ b/test/mail/0237.CALLER @@ -30,11 +30,11 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;/a/b/c +Final-Recipient: rfc822;/a/b/c@no.test.ex Status: 5.0.0 Action: failed -Final-Recipient: rfc822;|/p/q/r +Final-Recipient: rfc822;|/p/q/r@no.test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -125,7 +125,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; the.local.host.name Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv +Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv@yes.test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0383.CALLER b/test/mail/0383.CALLER index d2e55b657..5fa158a16 100644 --- a/test/mail/0383.CALLER +++ b/test/mail/0383.CALLER @@ -75,7 +75,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; myhost.test.ex Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv $thisaddress $1 +Final-Recipient: rfc822;system-filter Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -170,7 +170,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; myhost.test.ex Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv $1 +Final-Recipient: rfc822;system-filter Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -266,7 +266,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; myhost.test.ex Action: failed -Final-Recipient: rfc822;|TESTSUITE/aux-fixed/showenv $thisaddress $1 +Final-Recipient: rfc822;redking@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0428.CALLER b/test/mail/0428.CALLER index ff0af0de3..8feca08bc 100644 --- a/test/mail/0428.CALLER +++ b/test/mail/0428.CALLER @@ -32,7 +32,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; mail.test.ex Action: failed -Final-Recipient: rfc822;userx-extra +Final-Recipient: rfc822;restrict-userx@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM @@ -86,7 +86,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; mail.test.ex Action: failed -Final-Recipient: rfc822;inbox +Final-Recipient: rfc822;restrict-userx@test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM diff --git a/test/mail/0508.postmaster b/test/mail/0508.postmaster index 4ff758a5b..bd36b3d63 100644 --- a/test/mail/0508.postmaster +++ b/test/mail/0508.postmaster @@ -40,7 +40,7 @@ Content-type: message/delivery-status Reporting-MTA: dns; myhost.test.ex Action: failed -Final-Recipient: rfc822;|/bin/echo "Some pipe output" +Final-Recipient: rfc822;userx@myhost.test.ex Status: 5.0.0 --NNNNNNNNNN-eximdsn-MMMMMMMMMM -- 2.30.2