* Mike Erdely <[EMAIL PROTECTED]> [061127 11:12]:
> Jim Razmus wrote:
> >I sent Bob a patch to fix some off by ones.  You want those patches or
> >you may inadvertently trap a host who has valid DNS records.
> 
> Care to share the patch?
> 
> >Jim
> 
> -ME
> 

Here you go.

Jim
Index: greyscanner
===================================================================
RCS file: /var/cvsroot/soekris/root/greyscanner,v
retrieving revision 1.3
retrieving revision 1.1
diff -u -r1.3 -r1.1
--- greyscanner 22 Nov 2006 20:24:33 -0000      1.3
+++ greyscanner 12 Nov 2006 19:44:50 -0000      1.1
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: greyscanner,v 1.3 2006/11/22 20:24:33 jtr2 Exp $
+# $Id: greyscanner,v 1.1 2006/11/12 19:44:50 jtr2 Exp $
 # Greytrapping daemon for OpenBSD spamd
 
 # Copyright (c) 2006 Bob Beck <[EMAIL PROTECTED]>.  All rights reserved.
@@ -177,18 +177,17 @@
            }
        }
     }
-    close (SPAMDB);
-    my $wi = keys %WHITE;
-    my $tr = keys %TRAPPED;
-    my $gr = keys %GREY;
+    my @wi = (keys %WHITE);
+    my @tr = (keys %TRAPPED);
+    my @gr = (keys %GREY);
     syslog ('debug',
-           "scanned $wi whitelisted, $tr trapped, $gr unique greys\n");
+           "scanned $#wi whitelisted, $#tr trapped, $#gr unique greys\n");
     
     foreach $grey (keys %GREY) {
        my $trapped = 0;
        
        # ignore if it's already done
-       next if ($TRAPPED{$grey} || $WHITE{$grey});
+       next if ($WHITE{$grey} || $TRAPPED{$grey});
        
        # check the senders. if any are malformed, give the host the boot.
        my @senders = split("\t", $FROM{$grey});
@@ -201,7 +200,8 @@
        }
        next if $trapped;
        
-       my $count = @senders;
+       my $count = $#senders;
+       $count++;
        my @rcpts = split("\t", $RCPT{$grey});
        # if the host has queued up more than our suspect threshold, look
        # at a few things...
@@ -220,9 +220,12 @@
                $s =~ s/[EMAIL PROTECTED]@//;
                $D{"$s"}++;
            }
-           my $rcount = keys %R;
-           my $scount = keys %S;
-           my $dcount = keys %D;
+           my @urcpts = keys %R;
+           my @usenders = keys %S;
+           my @udoms = keys %D;
+           my $rcount = $#urcpts;
+           my $scount = $#usenders;
+           my $dcount = $#udoms;
            
            if ($dcount > $MAX_DOMAINS) {
                $reason = "Host sending from " . $dcount .
@@ -303,7 +306,7 @@
     my $res = Net::DNS::Resolver->new;
     my @domains = (keys %SENDERS);
 
-    while (scalar @domains > 0) {
+    while ($#domains > 0) {
        my @active = $sel->handles;
        while ($#active < $DNS_SOCK_MAX - 1) {
            # queue up a query for this domain.

Reply via email to