From 8ea31a40616fed2ee5520e5ac4b076f932d8680e Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 23 Dec 2012 22:51:11 +0000 Subject: [PATCH] Testsuite script for server-side PRDR. --- src/src/transports/smtp.c | 34 +++++++++++++++++++-- src/src/verify.c | 2 ++ test/confs/5500 | 60 +++++++++++++++++++++++++++++++++++++ test/scripts/5500-PRDR/5500 | 35 ++++++++++++++++++++++ 4 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 test/confs/5500 create mode 100644 test/scripts/5500-PRDR/5500 diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 505e0e8ee..ae5627ed8 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -1075,9 +1075,31 @@ goto SEND_QUIT; #endif #ifdef EXPERIMENTAL_PRDR + DEBUG(D_transport) debug_printf("considering PRDR...\n"); + prdr_enable = esmtp && - pcre_exec(regex_PRDR, NULL, CS buffer, Ustrlen(buffer), 0, - PCRE_EOPT, NULL, 0) >= 0; + (pcre_exec(regex_PRDR, NULL, CS buffer, Ustrlen(buffer), 0, + PCRE_EOPT, NULL, 0) >= 0) && + (verify_check_this_host(&(ob->hosts_try_prdr), NULL, host->name, + host->address, NULL) == OK); + DEBUG(D_transport) debug_printf("considered PRDR...\n"); + + if (prdr_enable) + {DEBUG(D_transport) debug_printf("PRDR usable\n");} + +else if (!esmtp) + {DEBUG(D_transport) debug_printf("PRDR not possible, not esmtp\n");} + +else if (pcre_exec(regex_PRDR, NULL, CS buffer, Ustrlen(buffer), 0, + PCRE_EOPT, NULL, 0) < 0) + {DEBUG(D_transport) debug_printf("PRDR not offerred\n");} + +else if (verify_check_this_host(&(ob->hosts_try_prdr), NULL, host->name, + host->address, NULL) != OK) + {DEBUG(D_transport) debug_printf("PRDR not permitted for host\n");} + +else + {DEBUG(D_transport) debug_printf("PRDR confusion\n");} #endif } @@ -1482,6 +1504,14 @@ if (smtp_use_size) while (*p) p++; } +#ifdef EXPERIMENTAL_PRDDR +if (prdr_enable) /*XXX could we do this on if >1 rcpts? */ + { + sprintf(CS p, " PRDR"); + p += 5; + } +#endif + /* If an authenticated_sender override has been specified for this transport instance, expand it. If the expansion is forced to fail, and there was already an authenticated_sender for this message, the original value will be used. diff --git a/src/src/verify.c b/src/src/verify.c index a1b8142a9..f17e36f01 100644 --- a/src/src/verify.c +++ b/src/src/verify.c @@ -607,6 +607,8 @@ else ) { uschar buffer2[4096]; +DEBUG(D_transport) + debug_printf("trying tls\n"); if ( !smtps && !(done= smtp_write_command(&outblock, FALSE, "STARTTLS\r\n") >= 0)) goto SEND_FAILED; diff --git a/test/confs/5500 b/test/confs/5500 new file mode 100644 index 000000000..0dcc81dae --- /dev/null +++ b/test/confs/5500 @@ -0,0 +1,60 @@ +# Exim test configuration 5500 +# Server PRDR + +LOG_SELECTOR= + +exim_path = EXIM_PATH +host_lookup_order = bydns +primary_hostname = myhost.test.ex +rfc1413_query_timeout = 0s +spool_directory = DIR/spool +log_file_path = DIR/spool/log/%slog +gecos_pattern = "" +gecos_name = CALLER_NAME + +# ----- Main settings ----- + +domainlist local_domains = test.ex : *.test.ex + +LOG_SELECTOR + +qualify_domain = test.ex +trusted_users = CALLER + +prdr_enable = true + +acl_smtp_rcpt = accept +acl_smtp_data = data_acl + +# ----- ACLs ----- + +begin acl + +data_acl: + deny local_parts = usery + accept + +# ----- Transports ----- + +begin transports + +t1: + driver = appendfile + file = DIR/test-mail/$local_part + user = CALLER + +# ----- Routers ----- + +begin routers + +r0: + driver = accept + transport = t1 + +# ----- Retry ----- + +begin retry + +* * F,5d,5m + +# End diff --git a/test/scripts/5500-PRDR/5500 b/test/scripts/5500-PRDR/5500 new file mode 100644 index 000000000..d7d76c67c --- /dev/null +++ b/test/scripts/5500-PRDR/5500 @@ -0,0 +1,35 @@ +# PRDR (Per-Recipient Data Responses) server +need_ipv4 +# +# usery should be rejected, x & z accepted, all after data per PRDR spec +exim -DSERVER=server -d -bd -oX PORT_D +**** +client 127.0.0.1 PORT_D +??? 220 +ehlo rhu.barb +??? 250- +??? 250- +??? 250- +??? 250- +??? 250-PRDR +??? 250 +mail from:<> PRDR +??? 250 +rcpt to: +??? 250 +rcpt to: +??? 250 +rcpt to: +??? 250 +data +??? 354 +Sender: sender@some.where +. +??? 353 +??? 250 +??? 550 +??? 250 +??? 250 +quit +??? 221 +**** -- 2.25.1