changeset 377:7fd39f029936

reject if dkim signer is listed on surbl
author Carl Byington <carl@five-ten-sg.com>
date Sat, 18 Feb 2017 15:06:32 -0800
parents 7ad7acf60758
children 5c3a3ddc1526
files ChangeLog NEWS configure.in dnsbl.spec.in src/dnsbl.cpp src/dnsbl.h
diffstat 6 files changed, 53 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Feb 08 11:40:44 2017 -0800
+++ b/ChangeLog	Sat Feb 18 15:06:32 2017 -0800
@@ -1,3 +1,6 @@
+6.50 2017-02-18
+    reject if dkim signer is listed on surbl
+
 6.49 2017-02-07
     RHEL7 systemd and /var/run on tmpfs.
 
--- a/NEWS	Wed Feb 08 11:40:44 2017 -0800
+++ b/NEWS	Sat Feb 18 15:06:32 2017 -0800
@@ -1,3 +1,4 @@
+6.50 2017-02-18 reject if dkim signer is listed on surbl
 6.49 2017-02-07 RHEL7 systemd and /var/run on tmpfs
 6.48 2016-12-17 Add dkim white/black listing
 6.47 2016-09-21 Better smtp verify logging
--- a/configure.in	Wed Feb 08 11:40:44 2017 -0800
+++ b/configure.in	Sat Feb 18 15:06:32 2017 -0800
@@ -1,6 +1,6 @@
 
 AC_PREREQ(2.59)
-AC_INIT(dnsbl,6.49,carl@five-ten-sg.com)
+AC_INIT(dnsbl,6.50,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_MACRO_DIR([m4])
--- a/dnsbl.spec.in	Wed Feb 08 11:40:44 2017 -0800
+++ b/dnsbl.spec.in	Sat Feb 18 15:06:32 2017 -0800
@@ -13,8 +13,10 @@
 Requires(pre):          /usr/sbin/useradd
 Requires(pre):          /usr/bin/getent
 Requires(postun):       /usr/sbin/userdel
-Requires(post,preun):   /sbin/chkconfig
-Requires(post,preun):   /sbin/service
+Requires(post):     /sbin/chkconfig
+Requires(preun):    /sbin/chkconfig
+Requires(post):     /sbin/service
+Requires(preun):    /sbin/service
 BuildRequires:          sendmail-devel >= 8.12.1
 BuildRequires:          spamassassin
 BuildRequires:          glibc-devel
@@ -152,6 +154,9 @@
 
 
 %changelog
+* Sat Feb 18 2017 Carl Byington <carl@five-ten-sg.com> - 6.50-1
+- reject if dkim signer is listed on surbl
+
 * Wed Feb 08 2017 Carl Byington <carl@five-ten-sg.com> - 6.49-1
 - RHEL7 systemd and /var/run is on tmpfs
 - install dnsblnogrey/whiteclnt for dccifd
--- a/src/dnsbl.cpp	Wed Feb 08 11:40:44 2017 -0800
+++ b/src/dnsbl.cpp	Sat Feb 18 15:06:32 2017 -0800
@@ -720,6 +720,16 @@
     return rs;
 }
 
+const char *mlfiPriv::check_uribl_signers() {
+    const char *st;
+    if (uribl_suffix) {
+        for (string_set::iterator s=dkim_signers.begin(); s!=dkim_signers.end(); s++) {
+            if (check_uribl(*this, hosts_uribl, *s, host_uribl)) return host_uribl;
+        }
+    }
+    return NULL;
+}
+
 void mlfiPriv::need_content_filter(CONTEXT &con) {
     if (!memory) {
         // first recipient that needs content filtering sets
@@ -1628,6 +1638,8 @@
         string_set whites;
         bool random = false;
         int  limit  = 0;
+        const char   *signer = NULL;
+        bool checked_signers = false;
         if (priv.dkim_signers.empty()) {
             snprintf(buf, sizeof(buf), "acceptable content from %s signer *",
                 (priv.fromaddr) ? priv.fromaddr : token_asterisk);
@@ -1653,10 +1665,27 @@
                 smfi_delrcpt(ctx, (char*)rcpt);
             }
             else if (st == token_unknown) {
+                if (!checked_signers) {
+                    signer = priv.check_uribl_signers();
+                    checked_signers = true;
+                    if (signer) {
+                        snprintf(buf, sizeof(buf), "dkim signer %s on uribl", signer);
+                        my_syslog(&priv, buf);
+                        snprintf(buf, sizeof(buf), "Mail rejected - dkim signed by %s", signer);
+                        msg = string(buf);
+                    }
+                }
+                if (signer) {
+                    // dkim signer is on the uribl
+                    smfi_delrcpt(ctx, (char*)rcpt);
+                }
+                else {
+                    // still unknown
                 unknowns.insert(rcpt);
                 random |= con.get_host_random();
                 limit   = max(limit, con.get_host_limit());
             }
+            }
             else if (st == token_white) {
                 whites.insert(rcpt);
             }
--- a/src/dnsbl.h	Wed Feb 08 11:40:44 2017 -0800
+++ b/src/dnsbl.h	Sat Feb 18 15:06:32 2017 -0800
@@ -49,8 +49,8 @@
     const char      *client_name;           // fully qualified host name of the smtp client xxx [ip.ad.dr.es] (may be forged)
           char      *client_dns_name;       // fully qualified host name of the smtp client xxx
     bool            client_dns_forged;      // rdns mismatch
-    const char      *host_uribl;            // pointer to helo/client/from host name if found on uribl
-    string_set      hosts_uribl;            // string set to hold the helo/client/from host name if found on uribl
+    const char      *host_uribl;            // pointer to helo/client/from/signer host name if found on uribl
+    string_set      hosts_uribl;            // string set to hold the helo/client/from/signer host name if found on uribl
     bool            helo_uribl;             // helo value on uribl
     bool            client_uribl;           // client_name on uribl
     bool            from_uribl;             // envelope from value on uribl
@@ -81,6 +81,7 @@
     void return_fd();
     size_t my_read(char *buf, size_t len);
     size_t my_write(const char *buf, size_t len);
+    const char *check_uribl_signers();
     void need_content_filter(CONTEXT &con);
 };