diff src/dnsbl.cpp @ 342:6d27b4f45799

allow envelope from whitelisting without dkim override for mail from localhost, or where the from address is root@*
author Carl Byington <carl@five-ten-sg.com>
date Fri, 23 Dec 2016 07:19:39 -0800
parents be776a246f97
children 891281cb6d3d
line wrap: on
line diff
--- a/src/dnsbl.cpp	Wed Dec 21 15:25:19 2016 -0800
+++ b/src/dnsbl.cpp	Fri Dec 23 07:19:39 2016 -0800
@@ -1242,6 +1242,9 @@
     const char *rcptaddr = rcpt[0];
     const char *loto     = to_lower_string(rcptaddr);
     bool self = (strcmp(loto, priv.mailaddr) == 0);
+    const u_char *src    = (const u_char *)&priv.ip;
+    bool local_source    = (src[0] == 127);
+    bool from_root       = (strncasecmp(priv.mailaddr, "root@", 5) == 0);
 
     // some version of sendmail allowed rcpt to:<> and passed it thru to the milters
     if (strcmp(loto, "<>") == 0) {
@@ -1291,9 +1294,12 @@
     else if (fromvalue == token_black) {
         st = black;
     }
+    else if ((fromvalue == token_white) && (local_source || from_root)) {
+        st = white;
+    }
     else if ((fromvalue == token_white) && !self) {
         // whitelisting based on envelope from value, but ignore it if
-        // we have a dkim requirement for that domain.
+        // we have a dkim requirement for that domain
         const char *domain = strchr(priv.mailaddr, '@');
         if (domain) {
             DKIMP dk = con.find_dkim_from(domain+1);
@@ -1396,8 +1402,7 @@
     if (len >= max_local_size) w = NULL;    // too big, pretend we don't have a whitelister
 
     // ignore auto whitelisting from outgoing mail from localhost
-    const u_char *src = (const u_char *)&priv.ip;
-    if (src[0] == 127) w = NULL;            // outgoing mail from localhost, pretend we don't have a whitelister
+    if (local_source) w = NULL;             // outgoing mail from localhost, pretend we don't have a whitelister
 
     // record it if we have a whitelister
     if (w) {