> -----Original Message----- > From: Billy Huddleston [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 01, 2006 3:58 PM > To: users@spamassassin.apache.org > Subject: Re: Relay Checker Plugin (code review please?) > > 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 > > > >
I added the patch in the part from: # header RELAY_CHECKER eval:relay_checker() # describe RELAY_CHECKER Check relay for DNS/Hostname issues. to: if ($nordns) { and when I run --lint I get the following errors: [21572] warn: Array found where operator expected at /etc/mail/spamassassin/RelayChecker.pm line 43, near "27 " [21572] warn: (Missing operator before ?) [21572] warn: plugin: failed to parse plugin /etc/mail/spamassassin/RelayChecker.pm: syntax error at /etc/mail/spamassassin/RelayChecker.pm line 44, near "27 @@ [21572] warn: " [21572] warn: Global symbol "$self" requires explicit package name at /etc/mail/spamassassin/RelayChecker.pm line 44. [21572] warn: syntax error at /etc/mail/spamassassin/RelayChecker.pm line 47, near "+sub parse_config " [21572] warn: Can't use global @_ in "my" at /etc/mail/spamassassin/RelayChecker.pm line 48, near "= @_" [21572] warn: plugin: failed to create instance of plugin RelayChecker: Undefined subroutine &RelayChecker::new called at (eval 848) line 1. [21572] warn: config: failed to parse line, skipping: - [21572] warn: config: failed to parse line, skipping: +rc_base_score .01 [21572] warn: config: failed to parse line, skipping: +rc_nordns_score 1 [21572] warn: config: failed to parse line, skipping: +rc_badrdns_score 1 [21572] warn: config: failed to parse line, skipping: +rc_baddns_score 1 [21572] warn: config: failed to parse line, skipping: +rc_ipinhostname_score .25 [21572] warn: config: failed to parse line, skipping: +rc_dynhostname_score 1 Am I doing something wrong? Running SA 3.1.7 and perl 5.8.5. Dylan