Fix $local_part_verified for remote-delivery routing following local. Bug 2565
authorJeremy Harris <jgh146exb@wizmail.org>
Fri, 1 May 2020 10:42:35 +0000 (11:42 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Fri, 1 May 2020 10:51:09 +0000 (11:51 +0100)
src/src/deliver.c
src/src/globals.c
src/src/macros.h
src/src/route.c
src/src/structs.h
test/confs/0587 [new file with mode: 0644]
test/log/0587 [new file with mode: 0644]
test/scripts/0000-Basic/0587 [new file with mode: 0644]
test/stdout/0587 [new file with mode: 0644]

index 810eb64..c8d7e83 100644 (file)
@@ -220,6 +220,7 @@ if (!addr->next)
   address_item *addr_orig;
 
   deliver_localpart = addr->local_part;
+  deliver_localpart_verified = addr->local_part_verified;
   deliver_localpart_prefix = addr->prefix;
   deliver_localpart_prefix_v = addr->prefix_v;
   deliver_localpart_suffix = addr->suffix;
index d00df97..d630df0 100644 (file)
@@ -187,6 +187,7 @@ const uschar **address_expansions[ADDRESS_EXPANSIONS_COUNT] = {
   CUSS &deliver_domain_orig,
   CUSS &deliver_domain_parent,
   CUSS &deliver_localpart,
+  CUSS &deliver_localpart_verified,
   CUSS &deliver_localpart_data,
   CUSS &deliver_localpart_orig,
   CUSS &deliver_localpart_parent,
index a6dbbf4..a507bbf 100644 (file)
@@ -119,7 +119,7 @@ don't make the file descriptors two-way. */
 verifying. This has to be explicit because it is referenced in more than one
 source module. */
 
-#define ADDRESS_EXPANSIONS_COUNT 18
+#define ADDRESS_EXPANSIONS_COUNT 19
 
 /* The maximum permitted number of command-line (-D) macro definitions. We
 need a limit only to make it easier to generate argument vectors for re-exec
index d0fbc8c..cee2f74 100644 (file)
@@ -959,7 +959,8 @@ if (r->check_local_user)
       r->name, addr->local_part);
     return SKIP;
     }
-  deliver_localpart_verified = string_copy(US (*pw)->pw_name);
+  addr->local_part_verified =
+    deliver_localpart_verified = string_copy(US (*pw)->pw_name);
   deliver_home = string_copy(US (*pw)->pw_dir);
   local_user_gid = (*pw)->pw_gid;
   local_user_uid = (*pw)->pw_uid;
@@ -973,22 +974,19 @@ confusing. */
 
 if (r->router_home_directory)
   {
-  uschar *router_home = expand_string(r->router_home_directory);
-  if (!router_home)
-    {
-    if (!f.expand_string_forcedfail)
-      {
-      *perror = string_sprintf("failed to expand \"%s\" for "
-        "router_home_directory: %s", r->router_home_directory,
-        expand_string_message);
-      return DEFER;
-      }
-    }
-  else
+  uschar * router_home = expand_string(r->router_home_directory);
+  if (router_home)
     {
     setflag(addr, af_home_expanded); /* Note set from router_home_directory */
     deliver_home = router_home;
     }
+  else if (!f.expand_string_forcedfail)
+    {
+    *perror = string_sprintf("failed to expand \"%s\" for "
+      "router_home_directory: %s", r->router_home_directory,
+      expand_string_message);
+    return DEFER;
+    }
   }
 
 /* Skip if the sender condition is not met. We leave this one till after the
@@ -1696,7 +1694,6 @@ for (r = addr->start_router ? addr->start_router : routers; r; r = nextr)
   the local part sorted. */
 
   router_name = r->name;
-  deliver_localpart_verified = NULL;
   deliver_set_expansions(addr);
 
   /* For convenience, the pre-router checks are in a separate function, which
index c6700d5..ae37f34 100644 (file)
@@ -553,6 +553,7 @@ typedef struct address_item {
   uschar *cc_local_part;          /* caseful local part */
   uschar *lc_local_part;          /* lowercased local part */
   uschar *local_part;             /* points to cc or lc version */
+  uschar *local_part_verified;    /* result from check_local_user */
   uschar *prefix;                 /* stripped prefix of local part */
   uschar *prefix_v;              /*  variable part of above */
   uschar *suffix;                 /* stripped suffix of local part */
diff --git a/test/confs/0587 b/test/confs/0587
new file mode 100644 (file)
index 0000000..a47ca66
--- /dev/null
@@ -0,0 +1,37 @@
+# Exim test configuration 0587
+
+.include DIR/aux-var/std_conf_prefix
+
+
+# ----- Main settings -----
+
+domainlist local_domains = @
+
+acl_smtp_rcpt = accept
+trusted_users = CALLER
+
+
+# ----- Routers -----
+
+begin routers
+
+dump_remote_domains:
+  driver = redirect
+  domains = ! +local_domains
+  data = :blackhole:
+
+localuser:
+  driver = accept
+  check_local_user
+  transport = local_delivery
+
+
+# ----- Transports -----
+
+begin transports
+
+local_delivery:
+  driver = appendfile
+  file = DIR/test-mail/$local_part_verified
+
+# End
diff --git a/test/log/0587 b/test/log/0587
new file mode 100644 (file)
index 0000000..851116d
--- /dev/null
@@ -0,0 +1,8 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= someone@some.domain U=CALLER P=local-smtp S=sss
+1999-03-02 09:44:33 10HmaX-0005vi-00 => :blackhole: <b@remote> R=dump_remote_domains
+1999-03-02 09:44:33 10HmaX-0005vi-00 => CALLER <CALLER@the.local.host.name> R=localuser T=local_delivery
+1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= someone@some.domain U=CALLER P=local-smtp S=sss
+1999-03-02 09:44:33 10HmaY-0005vi-00 => :blackhole: <a@remote> R=dump_remote_domains
+1999-03-02 09:44:33 10HmaY-0005vi-00 => CALLER <CALLER@the.local.host.name> R=localuser T=local_delivery
+1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
diff --git a/test/scripts/0000-Basic/0587 b/test/scripts/0000-Basic/0587
new file mode 100644 (file)
index 0000000..269cdb8
--- /dev/null
@@ -0,0 +1,18 @@
+# $local_part_verified, multi-rcpt message
+#
+exim -bs -odi
+mail from:<someone@some.domain>
+rcpt to:<CALLER@HOSTNAME>
+rcpt to:<b@remote>
+data
+.
+quit
+****
+exim -bs -odi
+mail from:<someone@some.domain>
+rcpt to:<a@remote>
+rcpt to:<CALLER@HOSTNAME>
+data
+.
+quit
+****
diff --git a/test/stdout/0587 b/test/stdout/0587
new file mode 100644 (file)
index 0000000..1c94559
--- /dev/null
@@ -0,0 +1,14 @@
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250 OK\r
+250 Accepted\r
+250 Accepted\r
+354 Enter message, ending with "." on a line by itself\r
+250 OK id=10HmaX-0005vi-00\r
+221 the.local.host.name closing connection\r
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250 OK\r
+250 Accepted\r
+250 Accepted\r
+354 Enter message, ending with "." on a line by itself\r
+250 OK id=10HmaY-0005vi-00\r
+221 the.local.host.name closing connection\r