spam.m4: No, we can't check domains in the DATA ACL.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 14 May 2014 08:54:56 +0000 (09:54 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 14 May 2014 08:54:56 +0000 (09:54 +0100)
Whoops.  We've been deferring for a while.  This is quite bad.

spam.m4

diff --git a/spam.m4 b/spam.m4
index 4253e88..9b7fe0d 100644 (file)
--- a/spam.m4
+++ b/spam.m4
@@ -103,18 +103,26 @@ skip_spam_check:
        accept   hosts = +trusted
        accept   condition = ${if eq{$acl_c_mode}{submission}}
 
-       ## If this is a virtual domain, and it says `spam-check=no', then
-       ## skip.
-       accept   domains = ${if exists{CONF_sysconf_dir/domains.conf} \
-                        {partial0-lsearch; CONF_sysconf_dir/domains.conf} \
-                        {}}
-               !condition = DOMKV(spam-check, {${expand:$value}}{true})
+       ## If all domains have disabled spam checking then don't check.
+       accept  !condition = $acl_c_spam_check_domain
 
        ## Otherwise we should check.
        deny
 
 rcpt_spam:
 
+       ## If this is a virtual domain, and it says `spam-check=no', then we
+       ## shouldn't check spam.  But we can't check domains at DATA time, so
+       ## instead we must track whether all recipients have disabled
+       ## checking.
+       warn    !domains = ${if exists{CONF_sysconf_dir/domains.conf} \
+                        {partial0-lsearch; CONF_sysconf_dir/domains.conf} \
+                        {}}
+                set acl_c_spam_check_domain = true
+       warn    !condition = $acl_c_spam_check_domain
+                condition = DOMKV(spam-check, {${expand:$value}}{true})
+                set acl_c_spam_check_domain = true
+
        ## See if we should do this check.
        accept   acl = skip_spam_check