$domain not always set when scanning a domain list.
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Tue, 31 Oct 2006 16:08:11 +0000 (16:08 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Tue, 31 Oct 2006 16:08:11 +0000 (16:08 +0000)
doc/doc-txt/ChangeLog
src/src/match.c
test/confs/0544 [new file with mode: 0644]
test/log/0544 [new file with mode: 0644]
test/scripts/0000-Basic/0544 [new file with mode: 0644]
test/stderr/0544 [new file with mode: 0644]
test/stdout/0544 [new file with mode: 0644]

index b3ac9316caf088a005b48752a9947f0b1e30c9a3..029026f4cda00c19d7c5817a82e5ac1eeb718974 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.422 2006/10/31 14:26:34 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.423 2006/10/31 16:08:11 ph10 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -226,6 +226,10 @@ PH/33 The hint "could be header name not terminated by colon", which has been
       given for certain expansion errors for a long time, was not being given
       for the ${if def:h_colon_omitted{...  case.
 
+PH/34 The spec says: "With one important exception, whenever a domain list is
+      being scanned, $domain contains the subject domain." There was at least
+      one case where this was not true.
+
 
 Exim version 4.63
 -----------------
index 238a2cdeaa2ab24892b9cc24c8cf8700c352f933..d70169899bdac3982b213767b483c682a1c5cf31 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/match.c,v 1.15 2006/07/27 13:50:43 ph10 Exp $ */
+/* $Cambridge: exim/src/src/match.c,v 1.16 2006/10/31 16:08:11 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -481,7 +481,19 @@ if (type >= MCL_NOEXPAND)
   }
 else
   {
-  list = expand_string(*listptr);
+  /* If we are searching a domain list, and $domain is not set, set it to the
+  subject that is being sought for the duration of the expansion. */
+
+  if (type == MCL_DOMAIN && deliver_domain == NULL)
+    {
+    check_string_block *cb = (check_string_block *)arg;
+    deliver_domain = cb->subject;
+    list = expand_string(*listptr);
+    deliver_domain = NULL;
+    }
+
+  else list = expand_string(*listptr);
+
   if (list == NULL)
     {
     if (expand_string_forcedfail)
diff --git a/test/confs/0544 b/test/confs/0544
new file mode 100644 (file)
index 0000000..f1a32b3
--- /dev/null
@@ -0,0 +1,70 @@
+# Exim test configuration 0544
+
+exim_path = EXIM_PATH
+host_lookup_order = bydns
+rfc1413_query_timeout = 0s
+spool_directory = DIR/spool
+log_file_path = DIR/spool/log/%slog
+gecos_pattern = ""
+gecos_name = CALLER_NAME
+
+# ----- Main settings -----
+
+domainlist dlist = testdb;$domain
+
+acl_smtp_helo = check_helo
+acl_smtp_mail = check_mail
+acl_smtp_rcpt = check_rcpt
+queue_smtp_domains = testdb;$domain
+qualify_domain = test.ex
+
+
+# ----- ACLs -----
+
+begin acl
+
+check_helo:
+  warn
+  condition = ${if match_domain {$sender_helo_name}{+dlist}}
+  accept
+
+
+check_mail:
+  warn  hosts = domain=$domain/sender_domain=$sender_address_domain
+  accept
+
+check_rcpt:
+  warn  domains = domain=$domain/sender_domain=$sender_address_domain
+  warn  sender_domains = domain=$domain/sender_domain=$sender_address_domain
+  accept
+
+
+# ----- Routers -----
+
+begin routers
+
+smarthost:
+  driver = accept
+  transport = smtp
+
+
+# ----- Transports -----
+
+begin transports
+
+smtp:
+  driver = smtp
+  hosts = 127.0.0.1
+  allow_localhost
+  port = PORT_S
+
+
+# ----- Retry -----
+
+
+begin retry
+
+* * F,5d,15m
+
+
+# End
diff --git a/test/log/0544 b/test/log/0544
new file mode 100644 (file)
index 0000000..9d519bb
--- /dev/null
@@ -0,0 +1,3 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@domain1.ex R=smarthost T=smtp defer (-1): domain matches queue_smtp_domains, or -odqs set
+1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@domain2.ex R=smarthost T=smtp defer (-1): domain matches queue_smtp_domains, or -odqs set
diff --git a/test/scripts/0000-Basic/0544 b/test/scripts/0000-Basic/0544
new file mode 100644 (file)
index 0000000..e886cfd
--- /dev/null
@@ -0,0 +1,13 @@
+# $domain setting in domain list matching
+need_ipv4
+#
+exim -odi -d-all+expand userx@domain1.ex userx@domain2.ex
+****
+# Check of $domain and $sender_domain at RCPT time
+exim -bs -d-all+expand
+ehlo ehlo.domain
+mail from:<userx@sender.domain>
+rcpt to:<userx@recipient.domain>
+quit
+****
+no_msglog_check
diff --git a/test/stderr/0544 b/test/stderr/0544
new file mode 100644 (file)
index 0000000..2d49eab
--- /dev/null
@@ -0,0 +1,109 @@
+Exim version x.yz ....
+configuration file is TESTSUITE/test-config
+admin user
+expanding: ${tod_full}
+   result: Tue, 2 Mar 1999 09:44:33 +0000
+condition: def:sender_rcvhost
+   result: false
+expanding: from $sender_rcvhost
+       
+   result: from 
+       
+skipping: result is not used
+condition: def:sender_ident
+   result: true
+expanding: $sender_ident
+   result: CALLER
+expanding: from ${quote_local_part:$sender_ident} 
+   result: from CALLER 
+condition: def:sender_helo_name
+   result: false
+expanding: (helo=$sender_helo_name)
+       
+   result: (helo=)
+       
+skipping: result is not used
+expanding: ${if def:sender_ident {from ${quote_local_part:$sender_ident} }}${if def:sender_helo_name {(helo=$sender_helo_name)
+       }}
+   result: from CALLER 
+condition: def:received_protocol
+   result: true
+expanding: with $received_protocol
+   result: with local
+condition: def:sender_address
+   result: true
+expanding: (envelope-from <$sender_address>)
+       
+   result: (envelope-from <CALLER@test.ex>)
+       
+condition: def:received_for
+   result: false
+expanding: 
+       for $received_for
+   result: 
+       for 
+skipping: result is not used
+expanding: ${tod_full}
+   result: Tue, 2 Mar 1999 09:44:33 +0000
+LOG: MAIN
+  <= CALLER@test.ex U=CALLER P=local S=sss
+created log directory TESTSUITE/spool/log
+Exim version x.yz ....
+configuration file is TESTSUITE/test-config
+trusted user
+admin user
+expanding: testdb;$domain
+   result: testdb;domain1.ex
+LOG: MAIN
+  == userx@domain1.ex R=smarthost T=smtp defer (-1): domain matches queue_smtp_domains, or -odqs set
+LOG: MAIN
+  == userx@domain2.ex R=smarthost T=smtp defer (-1): domain matches queue_smtp_domains, or -odqs set
+expanding: $h_list-id:$h_list-post:$h_list-subscribe:
+   result: 
+expanding: 
+   result: 
+expanding: $h_precedence:
+   result: 
+expanding: (?i)bulk|list|junk
+   result: (?i)bulk|list|junk
+expanding: $h_auto-submitted:
+   result: 
+expanding: (?i)auto-generated|auto-replied
+   result: (?i)auto-generated|auto-replied
+condition: or {{ !eq{$h_list-id:$h_list-post:$h_list-subscribe:}{} }{ match{$h_precedence:}{(?i)bulk|list|junk} }{ match{$h_auto-submitted:}{(?i)auto-generated|auto-replied} }}
+   result: false
+expanding: no
+   result: no
+skipping: result is not used
+expanding: yes
+   result: yes
+expanding: ${if or {{ !eq{$h_list-id:$h_list-post:$h_list-subscribe:}{} }{ match{$h_precedence:}{(?i)bulk|list|junk} }{ match{$h_auto-submitted:}{(?i)auto-generated|auto-replied} }} {no}{yes}}
+   result: yes
+>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
+>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
+Exim version x.yz ....
+configuration file is TESTSUITE/test-config
+admin user
+LOG: smtp_connection MAIN
+  SMTP connection from CALLER
+expanding: $smtp_active_hostname ESMTP Exim $version_number $tod_full
+   result: the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+expanding: $sender_helo_name
+   result: ehlo.domain
+expanding: +dlist
+   result: +dlist
+expanding: testdb;$domain
+   result: testdb;ehlo.domain
+condition: match_domain {$sender_helo_name}{+dlist}
+   result: true
+expanding: ${if match_domain {$sender_helo_name}{+dlist}}
+   result: true
+expanding: domain=$domain/sender_domain=$sender_address_domain
+   result: domain=/sender_domain=sender.domain
+expanding: domain=$domain/sender_domain=$sender_address_domain
+   result: domain=recipient.domain/sender_domain=sender.domain
+expanding: domain=$domain/sender_domain=$sender_address_domain
+   result: domain=recipient.domain/sender_domain=sender.domain
+LOG: smtp_connection MAIN
+  SMTP connection from CALLER closed by QUIT
+>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
diff --git a/test/stdout/0544 b/test/stdout/0544
new file mode 100644 (file)
index 0000000..9d9fa56
--- /dev/null
@@ -0,0 +1,8 @@
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250-the.local.host.name Hello CALLER at ehlo.domain\r
+250-SIZE 52428800\r
+250-PIPELINING\r
+250 HELP\r
+250 OK\r
+250 Accepted\r
+221 the.local.host.name closing connection\r