Testsuite script for server-side PRDR.
authorJeremy Harris <jgh146exb@wizmail.org>
Sun, 23 Dec 2012 22:51:11 +0000 (22:51 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Tue, 25 Dec 2012 12:09:37 +0000 (12:09 +0000)
src/src/transports/smtp.c
src/src/verify.c
test/confs/5500 [new file with mode: 0644]
test/scripts/5500-PRDR/5500 [new file with mode: 0644]

index 505e0e8eea290e78401be4b799cb80ad0f154f58..ae5627ed8cef16a7916728fff89d0c0ee1512f2d 100644 (file)
@@ -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.
index a1b8142a9e75346571e47685374cde0e36078105..f17e36f01707a1a13e72453184e9141b6acce7c6 100644 (file)
@@ -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 (file)
index 0000000..0dcc81d
--- /dev/null
@@ -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 (file)
index 0000000..d7d76c6
--- /dev/null
@@ -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:<userx@test.ex>
+??? 250
+rcpt to:<usery@test.ex>
+??? 250
+rcpt to:<userz@test.ex>
+??? 250
+data
+??? 354
+Sender: sender@some.where
+.
+??? 353
+??? 250
+??? 550
+??? 250
+??? 250
+quit
+??? 221
+****