From ad49a39a17e16ddc66571325a2cae70e925f98bb Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 12 Jan 2013 22:07:04 +0000 Subject: [PATCH] Fix handling of client PRDR final data-fail. --- src/src/transports/smtp.c | 18 +++++++--- test/log/5510 | 11 +++--- test/scripts/5500-PRDR/5510 | 67 ++++++++++++++++++------------------- test/stdout/5510 | 33 ++++++++++++++++-- 4 files changed, 82 insertions(+), 47 deletions(-) diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 9a5d02421..8873640ec 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -1855,14 +1855,16 @@ if (!ok) ok = TRUE; else errno = ERRNO_DATA4XX; addr->more_errno |= ((buffer[1] - '0')*10 + buffer[2] - '0') << 8; addr->transport_return = DEFER; - retry_add_item(addr, addr->address_retry_key, 0); +#ifdef EXPERIMENTAL_PRDR + if (!prdr_active) +#endif + retry_add_item(addr, addr->address_retry_key, 0); } continue; } completed_address = TRUE; /* NOW we can set this flag */ if ((log_extra_selector & LX_smtp_confirmation) != 0) { -/*XXX ought to have some specific logging of PRDR used, too */ uschar *s = string_printing(buffer); conf = (s == buffer)? (uschar *)string_copy(s) : s; } @@ -1907,7 +1909,7 @@ if (!ok) ok = TRUE; else if (prdr_active) { /* PRDR - get the final, overall response. For any non-success - overwrite all the address statuses. + upgrade all the address statuses. */ ok = smtp_read_response(&inblock, buffer, sizeof(buffer), '2', ob->final_timeout); if (!ok) @@ -1917,23 +1919,29 @@ if (!ok) ok = TRUE; else errno = ERRNO_DATA4XX; addrlist->more_errno |= ((buffer[1] - '0')*10 + buffer[2] - '0') << 8; } + for (addr = addrlist; addr != first_addr; addr = addr->next) + if (buffer[0] == '5' || addr->transport_return == OK) + addr->transport_return = PENDING_OK; /* allow set_errno action */ goto RESPONSE_FAILED; } - /* Update the journal. */ + /* Update the journal, or setup retry. */ for (addr = addrlist; addr != first_addr; addr = addr->next) + if (addr->transport_return == OK) { if (testflag(addr, af_homonym)) sprintf(CS buffer, "%.500s/%s\n", addr->unique + 3, tblock->name); else sprintf(CS buffer, "%.500s\n", addr->unique); - DEBUG(D_deliver) debug_printf("journalling %s", buffer); + DEBUG(D_deliver) debug_printf("journalling(PRDR) %s", buffer); len = Ustrlen(CS buffer); if (write(journal_fd, buffer, len) != len) log_write(0, LOG_MAIN|LOG_PANIC, "failed to write journal for " "%s: %s", buffer, strerror(errno)); } + else if (addr->transport_return == DEFER) + retry_add_item(addr, addr->address_retry_key, -2); } #endif diff --git a/test/log/5510 b/test/log/5510 index 19bddf192..4f586c958 100644 --- a/test/log/5510 +++ b/test/log/5510 @@ -5,11 +5,12 @@ 1999-03-02 09:44:33 10HmaY-0005vi-00 <= userx@test.ex U=CALLER P=local S=sss 1999-03-02 09:44:33 10HmaY-0005vi-00 => usery@test.ex R=r0 T=t1 H=127.0.0.1 [127.0.0.1] PRDR C="250 first rcpt was good" 1999-03-02 09:44:33 10HmaY-0005vi-00 == userz@test.ex R=r0 T=t1 defer (0): PRDR error after DATA: 450 cannot handle second rcpt right now -1999-03-02 09:44:33 10HmaZ-0005vi-00 <= userx@test.ex U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmaZ-0005vi-00 <= <> U=CALLER P=local S=sss 1999-03-02 09:44:33 10HmaZ-0005vi-00 => userp@test.ex R=r0 T=t1 H=127.0.0.1 [127.0.0.1] PRDR C="250 first rcpt was good" 1999-03-02 09:44:33 10HmaZ-0005vi-00 ** userq@test.ex R=r0 T=t1: PRDR error after DATA: 550 second rcpt does not like content -1999-03-02 09:44:33 10HmbA-0005vi-00 <= <> R=10HmaZ-0005vi-00 U=EXIMUSER P=local S=sss +1999-03-02 09:44:33 10HmaZ-0005vi-00 Frozen (delivery error message) 1999-03-02 09:44:33 10HmaY-0005vi-00 == userz@test.ex routing defer (-51): retry time not reached -1999-03-02 09:44:33 10HmbA-0005vi-00 Remote host 127.0.0.1 [127.0.0.1] closed connection in response to initial connection -1999-03-02 09:44:33 10HmbA-0005vi-00 == userx@test.ex R=r0 T=t1 defer (-18): Remote host 127.0.0.1 [127.0.0.1] closed connection in response to initial connection -1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed +1999-03-02 09:44:33 10HmbA-0005vi-00 <= <> U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmbA-0005vi-00 ** user4.1@test.ex R=r0 T=t1 H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after end of data: host 127.0.0.1 [127.0.0.1]: 550 oops, overall rejection +1999-03-02 09:44:33 10HmbA-0005vi-00 ** user4.2@test.ex R=r0 T=t1 H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after end of data: host 127.0.0.1 [127.0.0.1]: 550 oops, overall rejection +1999-03-02 09:44:33 10HmbA-0005vi-00 Frozen (delivery error message) diff --git a/test/scripts/5500-PRDR/5510 b/test/scripts/5500-PRDR/5510 index cf5574a94..1885a8a5f 100644 --- a/test/scripts/5500-PRDR/5510 +++ b/test/scripts/5500-PRDR/5510 @@ -58,9 +58,8 @@ Some message text. # # # 3: Two recipients, one accepted one rejected -# Oddly the client never gives us QUIT, just drops the conn. -# Perhaps due to the outstanding bounce for userx ? It is -# fine if the preceding tests are commented out. +# Avoid issues dealing with the bounce by sending +# with a null from. # server PORT_S 220 Server ready @@ -68,7 +67,7 @@ EHLO 250- 250-PRDR 250 OK -MAIL FROM: PRDR +MAIL FROM:<> PRDR 250 OK RCPT TO 250 OK @@ -84,37 +83,37 @@ DATA QUIT 250 OK **** -exim -odi -f userx userp userq +exim -odi -f "" userp userq Some message text. **** # # -## 4: Two recipients, rejected by final. -## -#server PORT_S -#220 Server ready -#EHLO -#250- -#250-PRDR -#250 OK -#MAIL FROM: PRDR -#250 OK -#RCPT TO -#250 OK -#RCPT TO -#250 OK -#DATA -#300 gimme yer body -#. -#353 prdr responses coming up -#250 first rcpt was good -#250 second rcpt was good -#550 Nope, overall rejection -#QUIT -#250 OK -#**** -#exim -d -odi -f userx user4.1 user4.2 -#text -#**** -## -## +# 4: Two recipients, rejected by final. +# +server PORT_S +220 Server ready +EHLO +250- +250-PRDR +250 OK +MAIL FROM:<> PRDR +250 OK +RCPT TO +250 OK +RCPT TO +250 OK +DATA +300 yeah baby +. +353 prdr responses coming up +250 first rcpt was good +250 second rcpt was good +550 oops, overall rejection +QUIT +250 OK +**** +exim -odi -f "" user4.1 user4.2 +text +**** +# +# diff --git a/test/stdout/5510 b/test/stdout/5510 index add2e2124..d8b53d2d0 100644 --- a/test/stdout/5510 +++ b/test/stdout/5510 @@ -69,7 +69,7 @@ EHLO myhost.test.ex 250- 250-PRDR 250 OK -MAIL FROM: PRDR +MAIL FROM:<> PRDR 250 OK RCPT TO: 250 OK @@ -78,10 +78,8 @@ RCPT TO: DATA 300 gimme yer body Received: from CALLER by myhost.test.ex with local (Exim x.yz) - (envelope-from ) id 10HmaZ-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 Message-Id: -From: userx@test.ex Date: Tue, 2 Mar 1999 09:44:33 +0000 Some message text. @@ -91,3 +89,32 @@ Some message text. 550 second rcpt does not like content 250 OK, overall Unexpected EOF read from client +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:<> PRDR +250 OK +RCPT TO: +250 OK +RCPT TO: +250 OK +DATA +300 yeah baby +Received: from CALLER by myhost.test.ex with local (Exim x.yz) + id 10HmbA-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +text +. +353 prdr responses coming up +250 first rcpt was good +250 second rcpt was good +550 oops, overall rejection +QUIT +250 OK +End of script -- 2.25.1