[exim-cvs] recipient verify callout

Top Page
Delete this message
Reply to this message
Author: Exim Git Commits Mailing List
Date:  
To: exim-cvs
Subject: [exim-cvs] recipient verify callout
Gitweb: http://git.exim.org/exim.git/commitdiff/9bfc60ebf1f86a212280c19a28bb4399e8fbb392
Commit:     9bfc60ebf1f86a212280c19a28bb4399e8fbb392
Parent:     9671784a54a6729881f7716a0b963a0422e8b3dd
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Wed Apr 8 21:33:51 2015 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sun Apr 12 23:29:45 2015 +0100


    recipient verify callout
---
 src/src/acl.c                        |    3 ++
 src/src/transports/smtp.c            |    2 +-
 src/src/verify.c                     |   50 ++++++++++++++++++++++++++-
 test/confs/4201                      |   25 ++++++++++---
 test/log/4201                        |   21 +++++++++++-
 test/rejectlog/4201                  |    3 ++
 test/runtest                         |    1 +
 test/scripts/4200-International/4201 |   63 +++++++++++++++++++++++++++++++++-
 test/stdout/4201                     |   44 +++++++++++++++++++++++
 9 files changed, 201 insertions(+), 11 deletions(-)


diff --git a/src/src/acl.c b/src/src/acl.c
index ea078f6..e16fbb9 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -4382,6 +4382,9 @@ if (where == ACL_WHERE_RCPT)
     *log_msgptr = US"defer in percent_hack_domains check";
     return DEFER;
     }
+#ifdef EXPERIMENTAL_INTERNATIONAL
+  addr->p.utf8 = message_smtputf8;
+#endif
   deliver_domain = addr->domain;
   deliver_localpart = addr->local_part;
   }
diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c
index ef2650a..c648855 100644
--- a/src/src/transports/smtp.c
+++ b/src/src/transports/smtp.c
@@ -574,7 +574,7 @@ if (*errno_value == ERRNO_WRITEINCOMPLETE)
 /* Handle lack of advertised SMTPUTF8, for international message */
 if (*errno_value == ERRNO_UTF8_FWD)
   {
-  *message = US string_sprintf("utf8 support required for forwarding");
+  *message = US string_sprintf("utf8 support required but not offerred for forwarding");
   DEBUG(D_deliver|D_transport) debug_printf("%s\n", *message);
   return TRUE;
   }
diff --git a/src/src/verify.c b/src/src/verify.c
index 678ee63..e39b55d 100644
--- a/src/src/verify.c
+++ b/src/src/verify.c
@@ -920,6 +920,25 @@ can do it there for the non-rcpt-verify case.  For this we keep an addresscount.
         }
       }


+#ifdef EXPERIMENTAL_INTERNATIONAL
+    else if (  addr->p.utf8
+        && !(  esmtp
+        && (  regex_UTF8
+           || ( (regex_UTF8 = regex_must_compile(
+              US"\\n250[\\s\\-]SMTPUTF8(\\s|\\n|$)", FALSE, TRUE)),
+              TRUE
+           )  )
+        && pcre_exec(regex_UTF8, NULL, CS responsebuffer,
+            Ustrlen(responsebuffer), 0, PCRE_EOPT, NULL, 0) >= 0
+        )   )
+      {
+      HDEBUG(D_acl|D_v) debug_printf("utf8 required but not offered\n");
+      errno = ERRNO_UTF8_FWD;
+      setflag(addr, af_verify_nsfail);
+      done = FALSE;
+      }
+#endif
+
     /* If we haven't authenticated, but are required to, give up. */
     /* Try to AUTH */


@@ -937,7 +956,13 @@ can do it there for the non-rcpt-verify case.  For this we keep an addresscount.
       ( (addr->auth_sndr = client_authenticated_sender),


     /* Send the MAIL command */
-        (smtp_write_command(&outblock, FALSE, "MAIL FROM:<%s>%s\r\n",
+        (smtp_write_command(&outblock, FALSE,
+#ifdef EXPERIMENTAL_INTERNATIONAL
+      addr->p.utf8
+      ? "MAIL FROM:<%s>%s SMTPUTF8\r\n"
+      :
+#endif
+        "MAIL FROM:<%s>%s\r\n",
           from_address, responsebuffer) >= 0)
       )  &&


@@ -1022,7 +1047,13 @@ can do it there for the non-rcpt-verify case.  For this we keep an addresscount.
             smtp_read_response(&inblock, responsebuffer, sizeof(responsebuffer),
               '2', callout) &&


-            smtp_write_command(&outblock, FALSE, "MAIL FROM:<%s>\r\n",
+            smtp_write_command(&outblock, FALSE,
+#ifdef EXPERIMENTAL_INTERNATIONAL
+          addr->p.utf8
+          ? "MAIL FROM:<%s> SMTPUTF8\r\n"
+          :
+#endif
+            "MAIL FROM:<%s>\r\n",
               from_address) >= 0 &&
             smtp_read_response(&inblock, responsebuffer, sizeof(responsebuffer),
               '2', callout);
@@ -1146,6 +1177,21 @@ can do it there for the non-rcpt-verify case.  For this we keep an addresscount.
         HDEBUG(D_verify) debug_printf("SMTP timeout\n");
         send_quit = FALSE;
         }
+#ifdef EXPERIMENTAL_INTERNATIONAL
+      else if (errno == ERRNO_UTF8_FWD)
+    {
+    extern int acl_where;    /* src/acl.c */
+    errno = 0;
+    addr->message = string_sprintf(
+        "response to \"%s\" from %s [%s] did not include SMTPUTF8",
+            big_buffer, host->name, host->address);
+        addr->user_message = acl_where == ACL_WHERE_RCPT
+      ? US"533 mailbox name not allowed"
+      : US"550 mailbox unavailable";
+    yield = FAIL;
+    done = TRUE;
+    }
+#endif
       else if (errno == 0)
         {
         if (*responsebuffer == 0) Ustrcpy(responsebuffer, US"connection dropped");
diff --git a/test/confs/4201 b/test/confs/4201
index aea4684..b34c7c1 100644
--- a/test/confs/4201
+++ b/test/confs/4201
@@ -2,6 +2,7 @@
 # SMTPUTF8 handling


OPTION = *
+CONTROL =

exim_path = EXIM_PATH
host_lookup_order = bydns
@@ -12,7 +13,7 @@ gecos_name = CALLER_NAME

# ----- Main settings -----

-domainlist local_domains = test.ex
+domainlist local_domains = test.ex : cname

acl_smtp_rcpt = check_recipient
acl_not_smtp = non_smtp
@@ -32,20 +33,32 @@ smtputf8_advertise_hosts = OPTION

begin acl

-check_recipient:

-.ifndef SERVER
-  accept domains = *
-.endif
+.ifdef SERVER
+
+check_recipient:
   accept hosts = :
   accept domains = +local_domains
+     local_parts = ^user.*\$
   deny   message = relay not permitted


-.ifndef SERVER
+.else
+
+sub:
+.ifdef CONTROL
+  require CONTROL
+.endif
+  accept
+
+check_recipient:
+  accept domains = *
+     acl = sub
+
 non_smtp:
   accept senders = :
      control = queue_only
   accept
+
 .endif


# ----- Routers -----
diff --git a/test/log/4201 b/test/log/4201
index fcaaba1..6d8260b 100644
--- a/test/log/4201
+++ b/test/log/4201
@@ -15,7 +15,7 @@
1999-03-02 09:44:33 End queue run: pid=pppp -qqff
1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225
1999-03-02 09:44:33 10HmbB-0005vi-00 <= यहलोगहिन्दीक्योंनहींबोलसकतेहैं@japanese.なぜみんな日本語を話してくれないのか.local U=CALLER P=utf8local-esmtp S=sss for userz@???
-1999-03-02 09:44:33 10HmbB-0005vi-00 ** userz@??? F=<यहलोगहिन्दीक्योंनहींबोलसकतेहैं@japanese.なぜみんな日本語を話してくれないのか.local> R=rmt T=rmt_smtp H=127.0.0.1 [127.0.0.1]: utf8 support required for forwarding
+1999-03-02 09:44:33 10HmbB-0005vi-00 ** userz@??? F=<यहलोगहिन्दीक्योंनहींबोलसकतेहैं@japanese.なぜみんな日本語を話してくれないのか.local> R=rmt T=rmt_smtp H=127.0.0.1 [127.0.0.1]: utf8 support required but not offerred for forwarding
1999-03-02 09:44:33 10HmbC-0005vi-00 <= <> R=10HmbB-0005vi-00 U=EXIMUSER P=local S=sss for यहलोगहिन्दीक्योंनहींबोलसकतेहैं@japanese.なぜみんな日本語を話してくれないのか.local
1999-03-02 09:44:33 10HmbC-0005vi-00 no immediate delivery: queued by ACL
1999-03-02 09:44:33 10HmbB-0005vi-00 Completed
@@ -23,3 +23,22 @@
1999-03-02 09:44:33 10HmbC-0005vi-00 => TESTSUITE/test-mail/यहलोगहिन्दीक्योंनहींबोलसकतेहैं <यहलोगहिन्दीक्योंनहींबोलसकतेहैं@japanese.なぜみんな日本語を話してくれないのか.local> F=<> R=bounces T=local_delivery
1999-03-02 09:44:33 10HmbC-0005vi-00 Completed
1999-03-02 09:44:33 End queue run: pid=pppp -qfl
+1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225
+1999-03-02 09:44:33 10HmbD-0005vi-00 <= 세계의모든사람들이한국어를이해한다면얼마나좋을까@russian.почемужеонинеговорятпорусски.com U=CALLER P=utf8local-esmtp S=sss for userQ@???
+1999-03-02 09:44:33 10HmbE-0005vi-00 <= 세계의모든사람들이한국어를이해한다면얼마나좋을까@russian.почемужеонинеговорятпорусски.com H=localhost (the.local.host.name) [127.0.0.1] P=utf8esmtp S=sss id=E10HmbD-0005vi-00@??? for userQ@???
+1999-03-02 09:44:33 10HmbD-0005vi-00 => userq@??? <userQ@???> F=<세계의모든사람들이한국어를이해한다면얼마나좋을까@russian.почемужеонинеговорятпорусски.com> R=rmt T=rmt_smtp H=127.0.0.1 [127.0.0.1] C="250 OK id=10HmbE-0005vi-00"
+1999-03-02 09:44:33 10HmbD-0005vi-00 Completed
+1999-03-02 09:44:33 H=localhost (the.local.host.name) [127.0.0.1] F=<> rejected RCPT <the.local.host.name-dddddddd-testing@???>: relay not permitted
+1999-03-02 09:44:33 10HmbF-0005vi-00 <= 세계의모든사람들이한국어를이해한다면얼마나좋을까@russian.почемужеонинеговорятпорусски.com U=CALLER P=utf8local-esmtp S=sss for userR@???
+1999-03-02 09:44:33 10HmbG-0005vi-00 <= 세계의모든사람들이한국어를이해한다면얼마나좋을까@russian.почемужеонинеговорятпорусски.com H=localhost (the.local.host.name) [127.0.0.1] P=utf8esmtp S=sss id=E10HmbF-0005vi-00@??? for userR@???
+1999-03-02 09:44:33 10HmbF-0005vi-00 => userr@??? <userR@???> F=<세계의모든사람들이한국어를이해한다면얼마나좋을까@russian.почемужеонинеговорятпорусски.com> R=rmt T=rmt_smtp H=127.0.0.1 [127.0.0.1] C="250 OK id=10HmbG-0005vi-00"
+1999-03-02 09:44:33 10HmbF-0005vi-00 Completed
+1999-03-02 09:44:33 Start queue run: pid=pppp -qqff
+1999-03-02 09:44:33 10HmbE-0005vi-00 => :blackhole: <userQ@???> R=localuser
+1999-03-02 09:44:33 10HmbE-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbG-0005vi-00 => :blackhole: <userR@???> R=localuser
+1999-03-02 09:44:33 10HmbG-0005vi-00 Completed
+1999-03-02 09:44:33 End queue run: pid=pppp -qqff
+1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225
+1999-03-02 09:44:33 U=CALLER F=<CALLER@???énopuedensimplementehablarenEspañol.local> rejected RCPT <userS@???>: response to "EHLO the.local.host.name" from 127.0.0.1 [127.0.0.1] did not include SMTPUTF8
+1999-03-02 09:44:33 U=CALLER F=<CALLER@???ạisaohọkhôngthểchỉnóitiếngViệt.local> rejected RCPT <userT@???>: response to "EHLO the.local.host.name" from 127.0.0.1 [127.0.0.1] did not include SMTPUTF8
diff --git a/test/rejectlog/4201 b/test/rejectlog/4201
new file mode 100644
index 0000000..efd8f15
--- /dev/null
+++ b/test/rejectlog/4201
@@ -0,0 +1,3 @@
+1999-03-02 09:44:33 H=localhost (the.local.host.name) [127.0.0.1] F=<> rejected RCPT <the.local.host.name-dddddddd-testing@???>: relay not permitted
+1999-03-02 09:44:33 U=CALLER F=<CALLER@???énopuedensimplementehablarenEspañol.local> rejected RCPT <userS@???>: response to "EHLO the.local.host.name" from 127.0.0.1 [127.0.0.1] did not include SMTPUTF8
+1999-03-02 09:44:33 U=CALLER F=<CALLER@???ạisaohọkhôngthểchỉnóitiếngViệt.local> rejected RCPT <userT@???>: response to "EHLO the.local.host.name" from 127.0.0.1 [127.0.0.1] did not include SMTPUTF8
diff --git a/test/runtest b/test/runtest
index 43ae1d4..4a44278 100755
--- a/test/runtest
+++ b/test/runtest
@@ -413,6 +413,7 @@ RESET_AFTER_EXTRA_LINE_READ:

# Random local part in callout cache testing
s/myhost.test.ex-\d+-testing/myhost.test.ex-dddddddd-testing/;
+ s/the.local.host.name-\d+-testing/the.local.host.name-dddddddd-testing/;

# File descriptor numbers may vary
s/^writing data block fd=\d+/writing data block fd=dddd/;
diff --git a/test/scripts/4200-International/4201 b/test/scripts/4200-International/4201
index d2fb96c..a697764 100644
--- a/test/scripts/4200-International/4201
+++ b/test/scripts/4200-International/4201
@@ -73,7 +73,6 @@ QUIT
#
#
killdaemon
-sleep 1
exim -DSERVER=server -qqff
****
#
@@ -100,3 +99,65 @@ killdaemon
#
exim -qfl
****
+#
+#
+#
+#
+#
+exim -DSERVER=server -bd -oX PORT_D
+****
+#
+# Recipient verify callout, pass
+exim -bs -odi -DCONTROL="verify=recipient/callout"
+EHLO client.bh
+MAIL FROM: <세계의모든사람들이한국어를이해한다면얼마나좋을까@russian.почемужеонинеговорятпорусски.com> SMTPUTF8
+RCPT TO: <userQ@???>
+DATA
+Subject: test
+
+body
+.
+QUIT
+****
+# Recipient+random verify callout, pass
+exim -bs -odi -DCONTROL="verify=recipient/callout=random"
+EHLO client.bh
+MAIL FROM: <세계의모든사람들이한국어를이해한다면얼마나좋을까@russian.почемужеонинеговорятпорусски.com> SMTPUTF8
+RCPT TO: <userR@???>
+DATA
+Subject: test
+
+body
+.
+QUIT
+****
+#
+killdaemon
+exim -DSERVER=server -qqff
+****
+#
+#
+#
+#
+#
+exim -DSERVER=server -DOPTION="" -bd -oX PORT_D
+****
+#
+# Recipient verify callout, fail
+exim -bs -odi -DCONTROL="verify=recipient/callout"
+EHLO client.ffail
+MAIL FROM: <CALLER@???énopuedensimplementehablarenEspañol.local> SMTPUTF8
+RCPT TO: <userS@???>
+QUIT
+****
+#
+# Recipient+random verify callout, fail
+exim -bs -odi -DCONTROL="verify=recipient/callout=random"
+EHLO client.ffail
+MAIL FROM: <CALLER@???ạisaohọkhôngthểchỉnóitiếngViệt.local> SMTPUTF8
+RCPT TO: <userT@???>
+QUIT
+****
+#
+killdaemon
+#
diff --git a/test/stdout/4201 b/test/stdout/4201
index e5f4886..9378243 100644
--- a/test/stdout/4201
+++ b/test/stdout/4201
@@ -92,3 +92,47 @@ End of script
354 Enter message, ending with "." on a line by itself
250 OK id=10HmbB-0005vi-00
221 the.local.host.name closing connection
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+250-the.local.host.name Hello CALLER at client.bh
+250-SIZE 52428800
+250-8BITMIME
+250-PIPELINING
+250-SMTPUTF8
+250 HELP
+250 OK
+250 Accepted
+354 Enter message, ending with "." on a line by itself
+250 OK id=10HmbD-0005vi-00
+221 the.local.host.name closing connection
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+250-the.local.host.name Hello CALLER at client.bh
+250-SIZE 52428800
+250-8BITMIME
+250-PIPELINING
+250-SMTPUTF8
+250 HELP
+250 OK
+250 Accepted
+354 Enter message, ending with "." on a line by itself
+250 OK id=10HmbF-0005vi-00
+221 the.local.host.name closing connection
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+250-the.local.host.name Hello CALLER at client.ffail
+250-SIZE 52428800
+250-8BITMIME
+250-PIPELINING
+250-SMTPUTF8
+250 HELP
+250 OK
+533 mailbox name not allowed
+221 the.local.host.name closing connection
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+250-the.local.host.name Hello CALLER at client.ffail
+250-SIZE 52428800
+250-8BITMIME
+250-PIPELINING
+250-SMTPUTF8
+250 HELP
+250 OK
+533 mailbox name not allowed
+221 the.local.host.name closing connection