changeset 246:8b0f16abee53 stable-6-0-28

Add prvs decoding to envelope addresses
author Carl Byington <carl@five-ten-sg.com>
date Fri, 30 Sep 2011 15:29:07 -0700
parents c7ccb14f91b4
children 33d080ace816
files ChangeLog NEWS configure.in dnsbl.spec.in src/dnsbl.cpp xml/dnsbl.in
diffstat 6 files changed, 34 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Aug 15 21:19:13 2011 -0700
+++ b/ChangeLog	Fri Sep 30 15:29:07 2011 -0700
@@ -1,3 +1,6 @@
+6.28 2011-09-30
+    Add prvs decoding to envelope addresses.
+
 6.27 2011-08-15
     const correctness fixes from new gcc
 
--- a/NEWS	Mon Aug 15 21:19:13 2011 -0700
+++ b/NEWS	Fri Sep 30 15:29:07 2011 -0700
@@ -1,3 +1,4 @@
+6.28 2011-09-30 Add prvs decoding to envelope addresses.
 6.27 2011-08-15 const correctness fixes from new gcc
 6.26 2010-11-19 64 bit fixes for libresolv.a
 6.25 2009-09-29 Add surbl checks on the smtp helo value, client reverse dns name, and mail from domain name.
--- a/configure.in	Mon Aug 15 21:19:13 2011 -0700
+++ b/configure.in	Fri Sep 30 15:29:07 2011 -0700
@@ -1,6 +1,6 @@
 
 AC_PREREQ(2.59)
-AC_INIT(dnsbl,6.27,carl@five-ten-sg.com)
+AC_INIT(dnsbl,6.28,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 
--- a/dnsbl.spec.in	Mon Aug 15 21:19:13 2011 -0700
+++ b/dnsbl.spec.in	Fri Sep 30 15:29:07 2011 -0700
@@ -103,6 +103,9 @@
 
 
 %changelog
+* Fri Sep 30 2011 Carl Byington <carl@five-ten-sg.com> - 6.28-1
+- Add prvs decoding to envelope addresses.
+
 * Mon Aug 15 2011 Carl Byington <carl@five-ten-sg.com> - 6.27-1
 - const correctness fixes from new gcc
 
--- a/src/dnsbl.cpp	Mon Aug 15 21:19:13 2011 -0700
+++ b/src/dnsbl.cpp	Fri Sep 30 15:29:07 2011 -0700
@@ -97,6 +97,7 @@
 int   generation = 0;       // protected by the config_mutex
 const int maxlen = 1000;    // used for snprintf buffers
 regex_t srs_pattern;        // used to detect srs coding in mail addresses
+regex_t prvs_pattern;       // used to detect prvs coding in mail addresses
 
 pthread_mutex_t  config_mutex;
 pthread_mutex_t  syslog_mutex;
@@ -991,7 +992,7 @@
 // that.  So the <> wrapper is now optional.  It may have mixed case, just
 // as the mail client sent it.  We dup the string and convert the duplicate
 // to lower case. Some clients enclose the entire address in single quotes,
-// so we strip those as well. We also remove the SRS coding.
+// so we strip those as well. We also remove the SRS and prvs coding.
 //
 const char *to_lower_string(const char *email);
 const char *to_lower_string(const char *email) {
@@ -1009,7 +1010,7 @@
     char *key = strdup(email);
     key[n] = '\0';
     for (int i=0; i<n; i++) key[i] = tolower(key[i]);
-    if ((n > 12) && (strncmp(key, "srs", 3) == 0)) {
+    if ((n > 14) && (strncmp(key, "srs", 3) == 0)) {
         // might have srs coding to be removed
         const int nmatch = 6;
         regmatch_t match[nmatch];
@@ -1030,6 +1031,19 @@
             }
         }
     }
+    if ((n > 7) && (strncmp(key, "prvs", 4) == 0)) {
+        // might have prvs coding to be removed
+        const int nmatch = 3;
+        regmatch_t match[nmatch];
+        if (0 == regexec(&prvs_pattern, key, nmatch, match, 0)) {
+            int s2 = match[2].rm_so;    // user@domain
+            if (s2 != -1) {
+                char *newkey = strdup(key+s2);  // user@domain
+                free(key);
+                key = newkey;
+            }
+        }
+    }
     return key;
 }
 
@@ -1559,11 +1573,17 @@
     extern char *optarg;
 
     // setup srs coding detection
-    if (regcomp(&srs_pattern, "^srs(0|1)=([^=]*)=([^=]*)=([^=]*)=([^@]*)@", REG_ICASE | REG_EXTENDED)) {
+    if (regcomp(&srs_pattern, "^srs(0|1)=([^=]+)=([^=]+)=([^=]+)=([^@]+)@", REG_ICASE | REG_EXTENDED)) {
         printf("cannot compile regex pattern to find srs coding in mail addresses\n");
         exit(3);
     }
 
+    // setup prvs coding detection
+    if (regcomp(&prvs_pattern, "^prvs=([^=]+)=(.+)$", REG_ICASE | REG_EXTENDED)) {
+        printf("cannot compile regex pattern to find prvs coding in mail addresses\n");
+        exit(3);
+    }
+
     // Process command line options
     while ((c = getopt(argc, argv, args)) != -1) {
         switch (c) {
--- a/xml/dnsbl.in	Mon Aug 15 21:19:13 2011 -0700
+++ b/xml/dnsbl.in	Fri Sep 30 15:29:07 2011 -0700
@@ -432,7 +432,9 @@
                 spamc), and the message is rejected for those recipients with spamassassin
                 limits less than the resulting spamassassin score. For example, a
                 spamassassin limit of three will reject messages with spamassassin scores
-                of four or greater.
+                of four or greater. If the filtering context has a spamassassin limit of
+                zero, then spamassassin is not called (or if called the results are not used)
+                for this recipient.
             </para>
             <para>
                 If any non-whitelisted recipient has a filtering context that specifies