From fee0c729b1c74ad1db8a0eb5fa3c0264365f0d95 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Mon, 14 Jan 2013 21:43:15 +0000 Subject: [PATCH] PRDR client should not request PRDR for 1-recipient mails. --- src/src/transports/smtp.c | 32 ++++++++++++++++++++++++++------ test/log/5510 | 3 +++ test/scripts/5500-PRDR/5510 | 29 ++++++++++++++++++++++++++--- test/stdout/5510 | 25 +++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 9 deletions(-) diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 8873640ec..144718a65 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -1288,6 +1288,17 @@ if (continue_hostname == NULL DEBUG(D_transport) debug_printf("%susing PIPELINING\n", smtp_use_pipelining? "" : "not "); +#ifdef EXPERIMENTAL_PRDR + prdr_offered = esmtp && + pcre_exec(regex_PRDR, NULL, CS buffer, Ustrlen(CS buffer), 0, + PCRE_EOPT, NULL, 0) >= 0 && + verify_check_this_host(&(ob->hosts_try_prdr), NULL, host->name, + host->address, NULL) == OK; + + if (prdr_offered) + {DEBUG(D_transport) debug_printf("PRDR usable\n");} +#endif + /* Note if the response to EHLO specifies support for the AUTH extension. If it has, check that this host is one we want to authenticate to, and do the business. The host name and address must be available when the @@ -1492,14 +1503,23 @@ if (smtp_use_size) } #ifdef EXPERIMENTAL_PRDR -if (prdr_offered) /*XXX limit to >1 rcpts? Need prdr_active flag */ +prdr_active = FALSE; +if (prdr_offered) { - prdr_active = TRUE; - sprintf(CS p, " PRDR"); - p += 5; + for (addr = first_addr; addr; addr = addr->next) + if (addr->transport_return == PENDING_DEFER) + { + for (addr = addr->next; addr; addr = addr->next) + if (addr->transport_return == PENDING_DEFER) + { /* at least two recipients to send */ + prdr_active = TRUE; + sprintf(CS p, " PRDR"); p += 5; + goto prdr_is_active; + } + break; + } } -else - prdr_active = FALSE; +prdr_is_active: #endif /* If an authenticated_sender override has been specified for this transport diff --git a/test/log/5510 b/test/log/5510 index 795c0b662..5cf25f1db 100644 --- a/test/log/5510 +++ b/test/log/5510 @@ -18,3 +18,6 @@ 1999-03-02 09:44:33 10HmbB-0005vi-00 == user5.1@test.ex R=r0 T=t1 defer (-46): SMTP error from remote mail server after end of data: host 127.0.0.1 [127.0.0.1]: 450 oops, try again later please 1999-03-02 09:44:33 10HmbB-0005vi-00 == user5.2@test.ex R=r0 T=t1 defer (-46): SMTP error from remote mail server after end of data: host 127.0.0.1 [127.0.0.1]: 450 oops, try again later please 1999-03-02 09:44:33 10HmbB-0005vi-00 == user5.3@test.ex R=r0 T=t1 defer (-46): SMTP error from remote mail server after end of data: host 127.0.0.1 [127.0.0.1]: 450 oops, try again later please +1999-03-02 09:44:33 10HmbC-0005vi-00 <= <> U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmbC-0005vi-00 => user6.1@test.ex R=r0 T=t1 H=127.0.0.1 [127.0.0.1] C="250 OK, got that" +1999-03-02 09:44:33 10HmbC-0005vi-00 Completed diff --git a/test/scripts/5500-PRDR/5510 b/test/scripts/5500-PRDR/5510 index 05ae4128e..8d6c899ca 100644 --- a/test/scripts/5500-PRDR/5510 +++ b/test/scripts/5500-PRDR/5510 @@ -2,7 +2,7 @@ need_ipv4 no_msglog_check # -# 1: Two recipients, accepted +# 1: Two recipients, accepted by full PRDR response sequence server PORT_S 220 Server ready EHLO @@ -59,7 +59,7 @@ Some message text. # # # 3: Two recipients, one accepted one rejected -# Avoid issues dealing with the bounce by sending +# Avoid tester issues dealing with the bounce by sending # with a null from. # server PORT_S @@ -150,4 +150,27 @@ text # # # -# 6 ? +# 8: Client should avoid requesting PRDR for a single-recipient mail +# even though the server offers +server PORT_S +220 Server ready +EHLO +250- +250-PRDR +250 OK +MAIL FROM:<> +250 OK +RCPT TO +250 OK +DATA +300 go ahead +. +250 OK, got that +QUIT +250 OK, bye +**** +exim -odi -f "" user6.1 +text +**** +# +# diff --git a/test/stdout/5510 b/test/stdout/5510 index 310058dfd..10842ed00 100644 --- a/test/stdout/5510 +++ b/test/stdout/5510 @@ -150,3 +150,28 @@ text QUIT 250 OK End of script +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Server ready +EHLO myhost.test.ex +250- +250-PRDR +250 OK +MAIL FROM:<> +250 OK +RCPT TO: +250 OK +DATA +300 go ahead +Received: from CALLER by myhost.test.ex with local (Exim x.yz) + id 10HmbC-0005vi-00 + for user6.1@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +text +. +250 OK, got that +QUIT +250 OK, bye +End of script -- 2.25.1