diff src/context.cpp @ 331:9800776436b9

allow dkim whitelisting to override uribl hosts in the mail body
author Carl Byington <carl@five-ten-sg.com>
date Mon, 19 Dec 2016 15:32:32 -0800
parents b5b93a7e1e6d
children ed04479a8e12
line wrap: on
line diff
--- a/src/context.cpp	Mon Dec 19 12:05:06 2016 -0800
+++ b/src/context.cpp	Mon Dec 19 15:32:32 2016 -0800
@@ -1108,7 +1108,7 @@
 }
 
 
-bool CONTEXT::acceptable_content(recorder &memory, int score, int bulk, const char *queueid, string_set &signers, const char *from, string& msg) {
+const char *CONTEXT::acceptable_content(recorder &memory, int score, int bulk, const char *queueid, string_set &signers, const char *from, string& msg) {
     DKIMP dk = find_dkim_from(from);
     bool requirement = false;
     for (string_set::iterator s=signers.begin(); s!=signers.end(); s++) {
@@ -1116,14 +1116,14 @@
         // signed by a white listed signer
         if (st == token_white) {
             log(queueid, "whitelisted dkim signer %s", *s);
-            return true;
+            return token_white;
         }
         // signed by a black listed signer
         if (st == token_black) {
             char buf[maxlen];
             snprintf(buf, sizeof(buf), "Mail rejected - dkim signed by %s", *s);
             msg = string(buf);
-            return false;
+            return token_black;
         }
 
         if (dk) {
@@ -1131,7 +1131,7 @@
             // signed by a white listed signer
             if ((st == token_signed_white)   && (strcasecmp(*s,dk->signer) == 0)) {
                 log(queueid, "whitelisted dkim signer %s", *s);
-                return true;
+                return token_white;
             }
             // signed by the required signer
             if ((st == token_require_signed) && (strcasecmp(*s,dk->signer) == 0)) {
@@ -1143,39 +1143,42 @@
                 char buf[maxlen];
                 snprintf(buf, sizeof(buf), "Mail rejected - dkim signed by %s", dk->signer);
                 msg = string(buf);
-                return false;
+                return token_black;
             }
         }
     }
 
-    if (dk && (dk->action == token_require_signed) && !requirement) {
+    if (dk && (dk->action == token_require_signed)) {
+        if (requirement) return token_white;
+        else {
         char buf[maxlen];
         snprintf(buf, sizeof(buf), "Mail rejected - not dkim signed by %s", dk->signer);
         msg = string(buf);
-        return false;
+            return token_black;
+        }
     }
 
     if (spamassassin_limit && (score > spamassassin_limit)) {
         char buf[maxlen];
         snprintf(buf, sizeof(buf), "Mail rejected - spam assassin score %d", score);
         msg = string(buf);
-        return false;
+        return token_black;
     }
     if (dcc_bulk_threshold && (bulk >= dcc_bulk_threshold)) {
         char buf[maxlen];
         snprintf(buf, sizeof(buf), "Mail rejected - dcc score %d", bulk);
         msg = string(buf);
-        return false;
+        return token_black;
     }
     if (memory.excessive_bad_tags(tag_limit)) {
         msg = string(tag_limit_message);
-        return false;
+        return token_black;
     }
     if (!host_random && memory.excessive_hosts(host_limit)) {
         msg = string(host_limit_message);
-        return false;
+        return token_black;
     }
-    return true;
+    return token_unknown;
 }