summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2020-05-01 11:42:35 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2020-05-01 11:51:09 +0100
commit37c0e209412be42f04a4599ecad6f901bff46f08 (patch)
treece613c9a46bd954820e64f962a9f86802aa6ea71
parent062364db7665faad5273818ac2c8f605ea48fdbe (diff)
Fix $local_part_verified for remote-delivery routing following local. Bug 2565
-rw-r--r--src/src/deliver.c1
-rw-r--r--src/src/globals.c1
-rw-r--r--src/src/macros.h2
-rw-r--r--src/src/route.c25
-rw-r--r--src/src/structs.h1
-rw-r--r--test/confs/058737
-rw-r--r--test/log/05878
-rw-r--r--test/scripts/0000-Basic/058718
-rw-r--r--test/stdout/058714
9 files changed, 92 insertions, 15 deletions
diff --git a/src/src/deliver.c b/src/src/deliver.c
index 810eb6452..c8d7e837a 100644
--- a/src/src/deliver.c
+++ b/src/src/deliver.c
@@ -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;
diff --git a/src/src/globals.c b/src/src/globals.c
index d00df9731..d630df030 100644
--- a/src/src/globals.c
+++ b/src/src/globals.c
@@ -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,
diff --git a/src/src/macros.h b/src/src/macros.h
index a6dbbf44d..a507bbf83 100644
--- a/src/src/macros.h
+++ b/src/src/macros.h
@@ -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
diff --git a/src/src/route.c b/src/src/route.c
index d0fbc8c5a..cee2f74c1 100644
--- a/src/src/route.c
+++ b/src/src/route.c
@@ -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
diff --git a/src/src/structs.h b/src/src/structs.h
index c6700d513..ae37f3461 100644
--- a/src/src/structs.h
+++ b/src/src/structs.h
@@ -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
index 000000000..a47ca664a
--- /dev/null
+++ b/test/confs/0587
@@ -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
index 000000000..851116d27
--- /dev/null
+++ b/test/log/0587
@@ -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
index 000000000..269cdb8b7
--- /dev/null
+++ b/test/scripts/0000-Basic/0587
@@ -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
index 000000000..1c9455905
--- /dev/null
+++ b/test/stdout/0587
@@ -0,0 +1,14 @@
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+250 OK
+250 Accepted
+250 Accepted
+354 Enter message, ending with "." on a line by itself
+250 OK id=10HmaX-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 OK
+250 Accepted
+250 Accepted
+354 Enter message, ending with "." on a line by itself
+250 OK id=10HmaY-0005vi-00
+221 the.local.host.name closing connection