Attached is patch to allow scores to be done in the .cf file

--- RelayChecker.pm     2006-10-30 18:02:28.000000000 -0500
+++ ../RelayChecker.pm  2006-11-01 15:36:53.000000000 -0500
@@ -31,6 +31,12 @@
# header        RELAY_CHECKER   eval:relay_checker()
# describe      RELAY_CHECKER   Check relay for DNS/Hostname issues.

+our $base_score = 4;
+our $nordns_score = 1;
+our $badrdns_score = 1;
+our $baddns_score = 1;
+our $ipinhostname_score = 1;
+our $dynhostname_score = 1;

sub new {
   my ($class, $mailsa) = @_;
@@ -44,6 +50,27 @@
   return $self;
   }

+sub parse_config {
+    my ( $self, $opts ) = @_;
+   if ( $opts->{key} eq "rc_base_score" ) {
+        $base_score = $opts->{value};
+   }
+   elsif ( $opts->{key} eq "rc_nordns_score" ) {
+        $nordns_score = $opts->{value};
+   }
+   elsif ( $opts->{key} eq "rc_badrdns_score" ) {
+        $badrdns_score = $opts->{value};
+   }
+   elsif ( $opts->{key} eq "rc_baddns_score" ) {
+        $baddns_score = $opts->{value};
+   }
+   elsif ( $opts->{key} eq "rc_ipinhostname_score" ) {
+        $ipinhostname_score = $opts->{value};
+   }
+   elsif ( $opts->{key} eq "rc_dynhostname_score" ) {
+        $dynhostname_score = $opts->{value};
+   }
+}

sub relay_checker {
   my ($self, $pms) = @_;
@@ -75,7 +102,7 @@
   if (! defined($hostname)) {
      # the IP address doesn't have a PTR record
      Mail::SpamAssassin::Plugin::dbg("RelayChecker: nordns");
-      $nordns = 1;
+      $nordns = $nordns_score;
      }
   else {
($name, $aliases, $addrtype, $length, @addrs) = gethostbyname($hostname);
@@ -83,7 +110,7 @@
      if (! defined($name)) {
         # the PTR record leads to a host that doesn't resolve in DNS
         Mail::SpamAssassin::Plugin::dbg("RelayChecker: badrdns");
-         $badrdns = 1;
+         $badrdns = $badrdns_score;
         }
      else {
         Mail::SpamAssassin::Plugin::dbg("RelayChecker: name is $name");
@@ -96,7 +123,7 @@
# the hostname in the PTR record does resolve, but that hostname
            # doesn't have $ip as one of its IP addresses
            Mail::SpamAssassin::Plugin::dbg("RelayChecker: baddns");
-            $baddns = 1;
+            $baddns = $baddns_score;
            }
         else {
            ($a, $b, $c, $d) = split(/\./, $ip); # decimal octets
@@ -124,7 +151,7 @@
               # in hex or decimal form ... or the entire thing in decimal
               # probably a spambot since this is an untrusted relay
Mail::SpamAssassin::Plugin::dbg("RelayChecker: ipinhostname");
-               $ipinhostname = 1;
+               $ipinhostname = $ipinhostname_score;
               }
            if ($hostname =~
      /(cable|catv|client|ddns|dhcp|dial-?up|dip|dsl|dynamic|ppp)\S*\.\S+\.\S+$/
@@ -136,7 +163,7 @@
               # hostname contains words that look dynamic
               # probably a spambot since this is an untrusted relay
Mail::SpamAssassin::Plugin::dbg("RelayChecker: dynhostname");
-               $dynhostname = 1;
+               $dynhostname = $dynhostname_score;
               }

            } # found ip addr
@@ -145,7 +172,7 @@

   $score = $nordns + $badrdns + $baddns + $ipinhostname + $dynhostname;
   if ($score) {
-      $score += 4;
+      $score += $base_score;
      my $description = $pms->{conf}->{description}->{RELAY_CHECKER};

      if ($nordns) {


--- RelayChecker.cf     2006-10-30 18:02:28.000000000 -0500
+++ ../RelayChecker.cf  2006-11-01 15:38:30.000000000 -0500
@@ -7,4 +7,9 @@
loadplugin      RelayChecker    RelayChecker.pm
header          RELAY_CHECKER   eval:relay_checker()
describe        RELAY_CHECKER   Check relay for DNS/Hostname issues
-
+rc_base_score  1.4
+rc_nordns_score        1
+rc_badrdns_score       1
+rc_baddns_score        1
+rc_ipinhostname_score  1
+rc_dynhostname_score   1







----- Original Message ----- From: "Andreas Pettersson" <[EMAIL PROTECTED]>
To: "Steven Dickenson" <[EMAIL PROTECTED]>
Cc: "John Rudd" <[EMAIL PROTECTED]>; "Giampaolo Tomassoni" <[EMAIL PROTECTED]>; <users@spamassassin.apache.org>
Sent: Wednesday, November 01, 2006 12:11 PM
Subject: Re: R: R: R: Relay Checker Plugin (code review please?)


Steven Dickenson wrote:

On Oct 31, 2006, at 6:09 AM, John Rudd wrote:

I've considered the exact opposite (adding static to the check for keywords). My rules are really looking more for "is this a _client_ host", not "is this a dynamic host". That one check looks for "dynamic", but I'm not interested in exempting anyone because they're "static". They've still got a hostname that looks like an end-client, and an end-client shouldn't be connecting to other people's mail servers. Any end-client that connects to someone else's email server should be treated like it's a spam/virus zombie


I can't agree with this. Many small businesses in the US get just these kind of static connections from broadband ISPs. Comcast, for example, has all of their static customers using rDNS that would fail your tests, and they refuse to set up a custom PTR record or delegate the record to someone else.


I disagree on your disagreement. This is my opinion: If you don't have control over your rDNS, do NOT run any mail server, unless you relay all outbound mail through a server at your ISP.

Most of these static customers are legitimate business networks running their own mail server, and have neither the need nor desire to relay their mail through Comcast's SMTP servers. I think your general idea is very good, but you're reaching a little too far with this one.


'No need nor desire', that's not really any good excuse. Use a relay or find your mail rejected, I'd say.

--
Andreas



Reply via email to