diff src/dnsbl.cpp @ 257:d11b529ce9c5 stable-6-0-31

Fix uribl lookups on client dns name, need to strip the ip address in brackets
author Carl Byington <carl@five-ten-sg.com>
date Sun, 01 Jul 2012 10:13:30 -0700
parents d6d5c50b9278
children be939802c64e
line wrap: on
line diff
--- a/src/dnsbl.cpp	Mon Apr 09 18:13:58 2012 -0700
+++ b/src/dnsbl.cpp	Sun Jul 01 10:13:30 2012 -0700
@@ -487,6 +487,7 @@
     queueid                 = NULL;
     authenticated           = NULL;
     client_name             = NULL;
+    client_dns_name         = NULL;
     host_uribl              = NULL;
     helo_uribl              = false;
     client_uribl            = false;
@@ -532,6 +533,7 @@
     if (queueid)       free((void*)queueid);
     if (authenticated) free((void*)authenticated);
     if (client_name)   free((void*)client_name);
+    if (client_dns_name) free((void*)client_dns_name);
     discard(hosts_uribl);
     delayer.clear();
     discard(env_to);
@@ -546,6 +548,7 @@
         queueid                 = NULL;
         authenticated           = NULL;
         client_name             = NULL;
+        client_dns_name         = NULL;
         host_uribl              = NULL;
         helo_uribl              = false;
         client_uribl            = false;
@@ -681,8 +684,10 @@
         if (uribl_suffix) {
             if (helo) {
                 helo_uribl = check_uribl(*this, hosts_uribl, helo, host_uribl);
-                if (client_name && !helo_uribl) {
-                    client_uribl = check_uribl(*this, hosts_uribl, client_name, host_uribl);
+            }
+            if (client_dns_name && !helo_uribl) {
+                client_uribl = check_uribl(*this, hosts_uribl, client_dns_name, host_uribl);
+            }
                     if (mailaddr && !client_uribl) {
                         const char *f = strchr(mailaddr, '@');
                         if (f) from_uribl = check_uribl(*this, hosts_uribl, f+1, host_uribl);
@@ -690,8 +695,6 @@
                 }
             }
         }
-    }
-}
 
 
 mlfiPriv* fetch_priv_from_ctx(SMFICTX *ctx);
@@ -1133,7 +1136,18 @@
     priv.client_name   = smfi_getsymval(ctx, (char*)"_");
     if (!priv.helo)         priv.helo          = strdup("unknown");
     if (priv.authenticated) priv.authenticated = strdup(priv.authenticated);
-    if (priv.client_name)   priv.client_name   = strdup(priv.client_name);
+    if (priv.client_name) {
+        priv.client_name = strdup(priv.client_name);
+        const char *p = strstr(priv.client_name, " [");
+        if (p) {
+            uint pp = p - priv.client_name;
+            priv.client_dns_name = strdup(priv.client_name);
+            priv.client_dns_name[pp] = '\0';
+            char text[500];
+            snprintf(text, sizeof(text), "found simple dns client name %s", priv.client_dns_name);
+            my_syslog(text);
+        }
+    }
     if (spamc != spamc_empty) {
         priv.assassin  = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid);
     }