ScamNailer update STILL not working

Mark Sapiro mark at msapiro.net
Wed Jun 19 21:13:14 IST 2013


On 06/19/2013 01:05 PM, Mark Sapiro wrote:
> 
> I have attached the latest version of my patch which works around this.


That patch contained a bit that isn't part of this issue. It wouldn't
hurt, but here's a patch without that extra bit.

-- 
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-06-19 13:08:56.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.
@@ -212,9 +213,23 @@
         last;
       }
     }
+    if ($currentbase == -1) {
+      $currentbase = 0;
+      $currentupdate = 0;
+      warn "No appropriate TXT found at $query.\n";
+    }
   }
 
-  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;
 
@@ -273,8 +288,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 +316,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
@@ -341,6 +364,7 @@
         }
       }
       close (FILEOUT);
+     }
     }
 
   }


More information about the MailScanner mailing list