* 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
> 

I'm seriously in need of coffee.  Try this instead.

Jim


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

Reply via email to