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 810eb64526fe29d8937dd0caa4d266941ffebd56..c8d7e837a68ae34c16c650d691741b62dc720c4b 100644 (file)
@@ -220,6 +220,7 @@ if (!addr->next)
   address_item *addr_orig;
 
   deliver_localpart = addr->local_part;
   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;
   deliver_localpart_prefix = addr->prefix;
   deliver_localpart_prefix_v = addr->prefix_v;
   deliver_localpart_suffix = addr->suffix;
index d00df97319d4c518cfe7d31ac124c424129c851f..d630df030e51c0df67c160cdeb95399d9f08b3c1 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_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,
   CUSS &deliver_localpart_data,
   CUSS &deliver_localpart_orig,
   CUSS &deliver_localpart_parent,
index a6dbbf44d20395bdd8276fd7cf0e05dd579348f1..a507bbf836914a316544b879d0a0d4b1e2892a4f 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. */
 
 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
 
 /* 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 d0fbc8c5aaa6df00be80625f7842c723d9d8657f..cee2f74c1ba47130d6dad13210d0dacc4c2f1616 100644 (file)
@@ -959,7 +959,8 @@ if (r->check_local_user)
       r->name, addr->local_part);
     return SKIP;
     }
       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;
   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)
   {
 
 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;
     }
     {
     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
   }
 
 /* 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;
   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
   deliver_set_expansions(addr);
 
   /* For convenience, the pre-router checks are in a separate function, which
index c6700d5136803fe8aa91d5fad96cc4e02b4b3517..ae37f346159a962d2e50ba98bdc27faa79e92d26 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 *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 */
   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