ScamNailer info not updated [solved]

Mark Sapiro mark at msapiro.net
Sun May 26 21:00:36 IST 2013


On Tue May 14 04:31:34 IST 2013, Mark Sapiro wrote:
> Since this doesn't seem to be getting fixed, I have patched ScamNailer
> with the attached patch which attempts to guess the current week and day
> for the base and then retrieves daily updates until it gets a 404.
> 
> This is working for me.
> 
> Caveat: I'm a perl novice. There may be a better way.


There is a minor issue with the patch I posted on May 14. Namely if
ScamNailer runs after retrieving updates in a prior run and there are no
new updates in this run, the cached updated file from the prior run gets
erased in this run. This causes a subsequent run to retrieve the base
and all the updates. The results are good, but it's extra work.

The patch attached here includes the prior patch plus a fix for this issue.

And yes this is still an issue. The DNS TXT record for
emails.msupdate.greylist.bastionmail.com is still not being updated.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
-------------- next part --------------
--- ScamNailer-2.10	2012-03-05 03:04:14.000000000 -0800
+++ ScamNailer.new	2013-05-26 12:45:21.000000000 -0700
@@ -18,6 +18,7 @@
 use LWP::UserAgent;
 use FileHandle;
 use DirHandle;
+use Time::Local;
 
 # Output filename, goes into SpamAssassin. Can be over-ridden by just
 # adding the output filename on the command-line when you run this script.
@@ -216,6 +217,16 @@
 
   die "Failed to retrieve valid current details\n" if $currentbase eq "-1";
 
+  my $day = (gmtime)[6];
+  my $year = (gmtime)[5] + 1900;
+  my $janone = (gmtime(timegm(0,0,0,1,0,$year-1900)))[6];
+  my $week = sprintf ("%02d", int (((gmtime)[7] + $janone) / 7));
+  my $mybase = "$year-$week$day";
+  if ($currentbase lt $mybase) {
+    $currentbase = $mybase;
+    $currentupdate = 99;
+  }
+
   print "I am working with: Current: $currentbase - $currentupdate and Status: $status_base - $status_update\n" unless $quiet;
 
   my $generate=0;
@@ -273,8 +284,10 @@
         #print "Getting $urlbase . $currentbase.$i\n" unless $quiet;
         my $req = HTTP::Request->new(GET => $urlbase.$currentbase.".".$i);
         my $res = $ua->request($req);
-        warn "Failed to retrieve $urlbase$currentbase.$i"
-          unless $res->is_success;
+        unless ($res->is_success) {
+          warn "Failed to retrieve $urlbase$currentbase.$i";
+          $currentupdate = $i - 1;
+        }
         my $line;
         foreach $line (split("\n", $res->content)) {
           # Is it an addition?
@@ -299,6 +312,12 @@
           }
         }
       }
+     # Because of our guess and retrieve until error strategy, we could be
+     # here without having retrieved any new updates which will result in
+     # our cached $status_update being erased. This does no real harm, but
+     # it causes extra work on the next run. To avoid this we skip the next
+     # section in that case.
+     if (!($status_update eq $currentupdate)) {
       # OK do we have a previous version to work from?
       if ($status_update>0) {
         # Yes - we open the most recent version
@@ -342,7 +361,7 @@
       }
       close (FILEOUT);
     }
-
+   }
   }
 
   # Changes have been made


More information about the MailScanner mailing list