Gitweb:
https://git.exim.org/exim.git/commitdiff/7616c28d51aad5dadbe4e8bc9ccee84b0a9b407c
Commit: 7616c28d51aad5dadbe4e8bc9ccee84b0a9b407c
Parent: 87ae73f8bea31b51fbcd6e1ae80742cd4d792308
Author: Jeremy Harris <jgh146exb@???>
AuthorDate: Thu Sep 7 16:40:39 2023 +0100
Committer: Jeremy Harris <jgh146exb@???>
CommitDate: Thu Sep 7 16:40:39 2023 +0100
Docs: example complex expansion for router domains condition
---
doc/doc-docbook/spec.xfpt | 19 ++-
test/aux-fixed/0403.accountfile | 3 +
test/confs/0403 | 24 ++--
test/log/0403 | 5 +-
test/scripts/0000-Basic/0403 | 6 +
test/stderr/0403 | 252 +++++++++++++++++++++++++++++++++++++++-
6 files changed, 292 insertions(+), 17 deletions(-)
diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index 04f2387cf..6ff06f3a4 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -19181,12 +19181,25 @@ This applies to all of the SRV, MX, AAAA, A lookup sequence.
.cindex "router" "restricting to specific domains"
.vindex "&$domain_data$&"
If this option is set, the router is skipped unless the current domain matches
-the list. If the match is achieved by means of a file lookup, the data that the
-lookup returned for the domain is placed in &$domain_data$& for use in string
+the list.
+The data returned by the list check
+is placed in &$domain_data$& for use in string
expansions of the driver's private options and in the transport.
See section &<<SECTrouprecon>>& for
a list of the order in which preconditions are evaluated.
+A complex example, using a file like:
+.code
+alice@dom1
+bill@dom1
+maggie@dom1
+.endd
+and checking both domain and local_part
+.code
+domains = ${domain:${lookup {$local_part@$domain} lseach,ret=key {/path/to/accountsfile}}}
+local_parts = ${local_part:${lookup {$local_part@$domain} lseach,ret=key {/path/to/accountsfile}}}
+.endd
+
.option driver routers string unset
@@ -19550,7 +19563,7 @@ example:
local_parts = dbm;/usr/local/specials/$domain_data
.endd
.vindex "&$local_part_data$&"
-If the match is achieved by a lookup, the data that the lookup returned
+the data returned by the list check
for the local part is placed in the variable &$local_part_data$& for use in
expansions of the router's private options or in the transport.
You might use this option, for
diff --git a/test/aux-fixed/0403.accountfile b/test/aux-fixed/0403.accountfile
new file mode 100644
index 000000000..8bfe64595
--- /dev/null
+++ b/test/aux-fixed/0403.accountfile
@@ -0,0 +1,3 @@
+alice@???
+bob@???
+charlie@???
diff --git a/test/confs/0403 b/test/confs/0403
index 26d1cd6fe..4fe478b09 100644
--- a/test/confs/0403
+++ b/test/confs/0403
@@ -14,13 +14,23 @@ qualify_domain = test.ex
begin routers
r1:
- driver = redirect
- domains = lsearch;DIR/aux-fixed/TESTNUM.data
- local_parts = lsearch;DIR/aux-fixed/TESTNUM.data
- address_data = ADDRESSDATA
- file_transport = t1
- data = DIR/test-mail/junk
- router_home_directory = /usr
+ driver = redirect
+ domains = ${domain:${lookup {$local_part@$domain} lsearch,ret=key {DIR/aux-fixed/TESTNUM.accountfile}}}
+ local_parts = ${local_part:${lookup {$local_part@$domain} lsearch,ret=key {DIR/aux-fixed/TESTNUM.accountfile}}}
+ file_transport = t1
+ data = DIR/test-mail/junk
+ debug_print = +++ROUTER:\n\
+ +++domain_data=$domain_data\n\
+ +++local_part_data=$local_part_data
+
+r2:
+ driver = redirect
+ domains = lsearch;DIR/aux-fixed/TESTNUM.data
+ local_parts = lsearch;DIR/aux-fixed/TESTNUM.data
+ address_data = ADDRESSDATA
+ file_transport = t1
+ data = DIR/test-mail/junk
+ router_home_directory = /usr
debug_print = +++ROUTER:\n\
+++domain_data=$domain_data\n\
+++local_part_data=$local_part_data\n\
diff --git a/test/log/0403 b/test/log/0403
index d4cb8b67c..700cade69 100644
--- a/test/log/0403
+++ b/test/log/0403
@@ -1,3 +1,6 @@
1999-03-02 09:44:33 10HmaX-000000005vi-0000 <= CALLER@??? U=CALLER P=local S=sss
-1999-03-02 09:44:33 10HmaX-000000005vi-0000 *> TESTSUITE/test-mail/junk <userx@???> R=r1 T=t1
+1999-03-02 09:44:33 10HmaX-000000005vi-0000 *> TESTSUITE/test-mail/junk <userx@???> R=r2 T=t1
1999-03-02 09:44:33 10HmaX-000000005vi-0000 Completed
+1999-03-02 09:44:33 10HmaY-000000005vi-0000 <= CALLER@??? U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmaY-000000005vi-0000 *> TESTSUITE/test-mail/junk <charlie@???> R=r1 T=t1
+1999-03-02 09:44:33 10HmaY-000000005vi-0000 Completed
diff --git a/test/scripts/0000-Basic/0403 b/test/scripts/0000-Basic/0403
index b6b3b6d47..749ff087c 100644
--- a/test/scripts/0000-Basic/0403
+++ b/test/scripts/0000-Basic/0403
@@ -1,4 +1,10 @@
# domain_data and local_part_data for redirection to file
exim -N -odi -d userx@???
****
+#
+#
+### _data from a multi-step expansion
+exim -N -odi -d charlie@???
+****
+#
no_message_check
diff --git a/test/stderr/0403 b/test/stderr/0403
index d231bffc3..ae0388347 100644
--- a/test/stderr/0403
+++ b/test/stderr/0403
@@ -86,6 +86,24 @@ userx@???: queued for routing
routing userx@???
--------> r1 router <--------
local_part=userx domain=test.ex
+checking domains
+ search_open: lsearch "TESTSUITE/aux-fixed/0403.accountfile"
+ search_find: file="TESTSUITE/aux-fixed/0403.accountfile"
+ key="userx@???" partial=-1 affix=NULL starflags=0 opts="ret=key"
+ LRU list:
+ 0TESTSUITE/aux-fixed/0403.accountfile
+ End
+ internal_search_find: file="TESTSUITE/aux-fixed/0403.accountfile"
+ type=lsearch key="userx@???" opts=NULL
+ file lookup required for userx@???
+ in TESTSUITE/aux-fixed/0403.accountfile
+ creating new cache entry
+ lookup failed
+test.ex in ""?
+test.ex in ""? no (end of list)
+r1 router skipped: domains mismatch
+--------> r2 router <--------
+local_part=userx domain=test.ex
checking domains
test.ex in "lsearch;TESTSUITE/aux-fixed/0403.data"?
list element: lsearch;TESTSUITE/aux-fixed/0403.data
@@ -94,6 +112,7 @@ test.ex in "lsearch;TESTSUITE/aux-fixed/0403.data"?
key="test.ex" partial=-1 affix=NULL starflags=0 opts=NULL
LRU list:
0TESTSUITE/aux-fixed/0403.data
+ 0TESTSUITE/aux-fixed/0403.accountfile
End
internal_search_find: file="TESTSUITE/aux-fixed/0403.data"
type=lsearch key="test.ex" opts=NULL
@@ -111,6 +130,7 @@ userx in "lsearch;TESTSUITE/aux-fixed/0403.data"?
key="userx" partial=-1 affix=NULL starflags=0 opts=NULL
LRU list:
0TESTSUITE/aux-fixed/0403.data
+ 0TESTSUITE/aux-fixed/0403.accountfile
End
internal_search_find: file="TESTSUITE/aux-fixed/0403.data"
type=lsearch key="userx" opts=NULL
@@ -125,18 +145,18 @@ userx in "lsearch;TESTSUITE/aux-fixed/0403.data"?
+++address_data=
+++home=/usr
processing address_data
-calling r1 router
+calling r2 router
rda_interpret (string): 'TESTSUITE/test-mail/junk'
expanded: 'TESTSUITE/test-mail/junk'
file is not a filter file
parse_forward_list: TESTSUITE/test-mail/junk
extract item: TESTSUITE/test-mail/junk
set transport t1
-r1 router generated TESTSUITE/test-mail/junk
+r2 router generated TESTSUITE/test-mail/junk
pipe, file, or autoreply
errors_to=NULL transport=t1
uid=unset gid=unset home=/usr
-routed by r1 router
+routed by r2 router
envelope to: userx@???
transport: <none>
locking TESTSUITE/spool/db/retry.lockfile
@@ -190,12 +210,12 @@ post-process TESTSUITE/test-mail/junk (0)
TESTSUITE/test-mail/junk delivered
userx@???: children all complete
LOG: MAIN
- *> TESTSUITE/test-mail/junk <userx@???> R=r1 T=t1
+ *> TESTSUITE/test-mail/junk <userx@???> R=r2 T=t1
>>>>>>>>>>>>>>>> deliveries are done >>>>>>>>>>>>>>>>
changed uid/gid: post-delivery tidying
uid=EXIM_UID gid=EXIM_GID pid=p1235
set_process_info: pppp tidying up after delivering 10HmaX-000000005vi-0000
-DSN: processing router : r1
+DSN: processing router : r2
DSN: processing successful delivery address: TESTSUITE/test-mail/junk
DSN: Sender_address: CALLER@???
DSN: orcpt: NULL flags: 0x0
@@ -203,7 +223,7 @@ DSN: envid: NULL ret: 0
DSN: Final recipient: TESTSUITE/test-mail/junk
DSN: Remote SMTP server supports DSN: 0
DSN: not sending DSN success message
-DSN: processing router : r1
+DSN: processing router : r2
DSN: processing successful delivery address: userx@???
DSN: Sender_address: CALLER@???
DSN: orcpt: NULL flags: 0x0
@@ -219,3 +239,223 @@ search_tidyup called
>>>>>>>>>>>>>>>> Exim pid=p1235 (local-accept-delivery) terminating with rc=0 >>>>>>>>>>>>>>>>
search_tidyup called
>>>>>>>>>>>>>>>> Exim pid=p1234 (fresh-exec) terminating with rc=0 >>>>>>>>>>>>>>>>
+### _data from a multi-step expansion
+Exim version x.yz ....
+changed uid/gid: forcing real = effective
+ uid=uuuu gid=CALLER_GID pid=p1237
+configuration file is TESTSUITE/test-config
+admin user
+changed uid/gid: privilege not needed
+ uid=EXIM_UID gid=EXIM_GID pid=p1237
+seeking password data for user "CALLER": cache not available
+getpwnam() succeeded uid=CALLER_UID gid=CALLER_GID
+originator: uid=CALLER_UID gid=CALLER_GID login=CALLER name=CALLER_NAME
+sender address = CALLER@???
+set_process_info: pppp accepting a local non-SMTP message from <CALLER@???>
+spool directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 msg_size = 0
+log directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100
+Sender: CALLER@???
+Recipients:
+ charlie@???
+search_tidyup called
+>>Headers received:
+
+qualify & rewrite recipients list
+global rewrite rules
+rewrite headers
+ rewrite_one_header: type=F:
+ From: CALLER_NAME <CALLER@???>
+search_tidyup called
+>>Headers after rewriting and local additions:
+I Message-Id: <E10HmaY-000000005vi-0000@???>
+F From: CALLER_NAME <CALLER@???>
+ Date: Tue, 2 Mar 1999 09:44:33 +0000
+
+Data file name: TESTSUITE/spool//input//10HmaY-000000005vi-0000-D
+Data file written for message 10HmaY-000000005vi-0000
+>>Generated Received: header line
+P Received: from CALLER by mail.test.ex with local (Exim x.yz)
+ (envelope-from <CALLER@???>)
+ id 10HmaY-000000005vi-0000
+ for charlie@???;
+ Tue, 2 Mar 1999 09:44:33 +0000
+Writing spool header file: TESTSUITE/spool//input//hdr.10HmaY-000000005vi-0000
+DSN: **** SPOOL_OUT - address: <charlie@???> errorsto: <NULL> orcpt: <NULL> dsn_flags: 0x0
+Renaming spool header file: TESTSUITE/spool//input//10HmaY-000000005vi-0000-H
+Size of headers = sss
+LOG: MAIN
+ <= CALLER@??? U=CALLER P=local S=sss
+search_tidyup called
+exec TESTSUITE/eximdir/exim -DEXIM_PATH=TESTSUITE/eximdir/exim -C TESTSUITE/test-config -d=0xf7715cfd -MCd local-accept-delivery -N -odi -Mc 10HmaY-000000005vi-0000
+Exim version x.yz ....
+changed uid/gid: forcing real = effective
+ uid=uuuu gid=EXIM_GID pid=p1238
+configuration file is TESTSUITE/test-config
+trusted user
+admin user
+dropping to exim gid; retaining priv uid
+seeking password data for user "CALLER": cache not available
+getpwnam() succeeded uid=CALLER_UID gid=CALLER_GID
+set_process_info: pppp delivering specified messages
+set_process_info: pppp delivering 10HmaY-000000005vi-0000
+Trying spool file TESTSUITE/spool//input//10HmaY-000000005vi-0000-D
+reading spool file 10HmaY-000000005vi-0000-H
+user=CALLER uid=CALLER_UID gid=CALLER_GID sender=CALLER@???
+sender_local=1 ident=CALLER
+Non-recipients:
+ Empty Tree
+---- End of tree ----
+recipients_count=1
+**** SPOOL_IN - No additional fields
+body_linecount=0 message_linecount=8
+DSN: set orcpt: flags: 0x0
+Delivery address list:
+ charlie@???
+ locking TESTSUITE/spool/db/retry.lockfile
+ locked TESTSUITE/spool/db/retry.lockfile
+ EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> flags=O_RDONLY
+ returned from EXIM_DBOPEN: (nil)
+ failed to open DB file TESTSUITE/spool/db/retry: No such file or directory
+no retry data available
+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+Considering: charlie@???
+unique = charlie@???
+no domain retry record
+no address retry record
+charlie@???: queued for routing
+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+routing charlie@???
+--------> r1 router <--------
+local_part=charlie domain=dom1.ain
+checking domains
+ search_open: lsearch "TESTSUITE/aux-fixed/0403.accountfile"
+ search_find: file="TESTSUITE/aux-fixed/0403.accountfile"
+ key="charlie@???" partial=-1 affix=NULL starflags=0 opts="ret=key"
+ LRU list:
+ 0TESTSUITE/aux-fixed/0403.accountfile
+ End
+ internal_search_find: file="TESTSUITE/aux-fixed/0403.accountfile"
+ type=lsearch key="charlie@???" opts=NULL
+ file lookup required for charlie@???
+ in TESTSUITE/aux-fixed/0403.accountfile
+ creating new cache entry
+ lookup yielded:
+dom1.ain in "dom1.ain"?
+ list element: dom1.ain
+ dom1.ain in "dom1.ain"? yes (matched "dom1.ain")
+checking local_parts
+ search_open: lsearch "TESTSUITE/aux-fixed/0403.accountfile"
+ cached open
+ search_find: file="TESTSUITE/aux-fixed/0403.accountfile"
+ key="charlie@???" partial=-1 affix=NULL starflags=0 opts="ret=key"
+ LRU list:
+ 0TESTSUITE/aux-fixed/0403.accountfile
+ End
+ internal_search_find: file="TESTSUITE/aux-fixed/0403.accountfile"
+ type=lsearch key="charlie@???" opts=NULL
+ cached data used for lookup of charlie@???
+ in TESTSUITE/aux-fixed/0403.accountfile
+ lookup yielded:
+charlie in "charlie"?
+ list element: charlie
+ charlie in "charlie"? yes (matched "charlie")
++++ROUTER:
++++domain_data=dom1.ain
++++local_part_data=charlie
+calling r1 router
+rda_interpret (string): 'TESTSUITE/test-mail/junk'
+expanded: 'TESTSUITE/test-mail/junk'
+file is not a filter file
+parse_forward_list: TESTSUITE/test-mail/junk
+extract item: TESTSUITE/test-mail/junk
+set transport t1
+r1 router generated TESTSUITE/test-mail/junk
+ pipe, file, or autoreply
+ errors_to=NULL transport=t1
+ uid=unset gid=unset home=NULL
+routed by r1 router
+ envelope to: charlie@???
+ transport: <none>
+ locking TESTSUITE/spool/db/retry.lockfile
+ locked TESTSUITE/spool/db/retry.lockfile
+ EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> flags=O_RDONLY
+ returned from EXIM_DBOPEN: (nil)
+ failed to open DB file TESTSUITE/spool/db/retry: No such file or directory
+no retry data available
+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+Considering: TESTSUITE/test-mail/junk
+unique = TESTSUITE/test-mail/junk:charlie@???
+queued for t1 transport
+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+After routing:
+ Local deliveries:
+ TESTSUITE/test-mail/junk
+ Remote deliveries:
+ Failed addresses:
+ Deferred addresses:
+search_tidyup called
+>>>>>>>>>>>>>>>> Local deliveries >>>>>>>>>>>>>>>>
+--------> TESTSUITE/test-mail/junk <--------
+ locking TESTSUITE/spool/db/retry.lockfile
+ locked TESTSUITE/spool/db/retry.lockfile
+ EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> flags=O_RDONLY
+ returned from EXIM_DBOPEN: (nil)
+ failed to open DB file TESTSUITE/spool/db/retry: No such file or directory
+no retry data available
+search_tidyup called
+changed uid/gid: local delivery to TESTSUITE/test-mail/junk <TESTSUITE/test-mail/junk> transport=t1
+ uid=CALLER_UID gid=CALLER_GID pid=p1239
+ home=NULL current=/
+set_process_info: pppp delivering 10HmaY-000000005vi-0000 to TESTSUITE/test-mail/junk using t1
++++TRANSPORT:
++++domain_data=dom1.ain
++++local_part_data=charlie
++++address_data=
++++home=
+appendfile transport entered
+appendfile: mode=600 notify_comsat=0 quota=0 warning=0
+ file=TESTSUITE/test-mail/junk format=unix
+ message_prefix=From ${if def:return_path{$return_path}{MAILER-DAEMON}} ${tod_bsdinbox}\n
+ message_suffix=\n
+ maildir_use_size_file=no
+ locking by lockfile fcntl
+*** delivery by t1 transport bypassed by -N option
+search_tidyup called
+journalling TESTSUITE/test-mail/junk:charlie@???
+t1 transport returned OK for TESTSUITE/test-mail/junk
+post-process TESTSUITE/test-mail/junk (0)
+TESTSUITE/test-mail/junk delivered
+charlie@???: children all complete
+LOG: MAIN
+ *> TESTSUITE/test-mail/junk <charlie@???> R=r1 T=t1
+>>>>>>>>>>>>>>>> deliveries are done >>>>>>>>>>>>>>>>
+changed uid/gid: post-delivery tidying
+ uid=EXIM_UID gid=EXIM_GID pid=p1238
+set_process_info: pppp tidying up after delivering 10HmaY-000000005vi-0000
+DSN: processing router : r1
+DSN: processing successful delivery address: TESTSUITE/test-mail/junk
+DSN: Sender_address: CALLER@???
+DSN: orcpt: NULL flags: 0x0
+DSN: envid: NULL ret: 0
+DSN: Final recipient: TESTSUITE/test-mail/junk
+DSN: Remote SMTP server supports DSN: 0
+DSN: not sending DSN success message
+DSN: processing router : r1
+DSN: processing successful delivery address: charlie@???
+DSN: Sender_address: CALLER@???
+DSN: orcpt: NULL flags: 0x0
+DSN: envid: NULL ret: 0
+DSN: Final recipient: charlie@???
+DSN: Remote SMTP server supports DSN: 0
+DSN: not sending DSN success message
+LOG: MAIN
+ Completed
+end delivery of 10HmaY-000000005vi-0000
+search_tidyup called
+search_tidyup called
+>>>>>>>>>>>>>>>> Exim pid=p1238 (local-accept-delivery) terminating with rc=0 >>>>>>>>>>>>>>>>
+search_tidyup called
+>>>>>>>>>>>>>>>> Exim pid=p1237 (fresh-exec) terminating with rc=0 >>>>>>>>>>>>>>>>
+
+******** SERVER ********
+### _data from a multi-step expansion
--
## subscription configuration (requires account):
##
https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at
http://www.exim.org/
## Please use the Wiki with this list -
http://wiki.exim.org/