You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Jeroen Hofstee <je...@virtualhost.nl> on 2009/01/17 20:40:12 UTC

POPAuthPlugin for tcpserver

Hello All,

When mail is accepted from a client by the local smtp server since it 
has authenticated before (POP / IMAP etc) and the intended rececpient is 
also on the local server (e.g. a college on the same domain) the message 
is often mark as spam since the last hop was a dynamic ip-address and 
there is no valid auth information available to spamassassin. In order 
to cope with this situation I encountered the POPAuthPlugin, 
http://wiki.apache.org/spamassassin/POPAuthPlugin. However, the 
POPAuthPlugin supports access.db (sendmail?) format but not the cdb as 
used by our system (vpopmail and smtp run on top of tcpserver), so I 
added a tiny bit of code, to read the cdb file instead. (code below, 
returns the same as _read_hash_db).

My question are:
+ Would it be useful to add this to the plugin?
+ If so, what is the procedure to do that?

Regards,
Jeroen Hofstee






---------------------------------------------------------------------------------------
sub _read_hash_cdb {
        my ($self) = @_;

        my %access;
        my %trusted;

        my $path = $self->{main}->{conf}->{popauth_hash_file};
        dbg("config: tie-ing to DB file R/O in $path");

        if (tie %access,"CDB_File",$path)
        {
                my ($key, $value);
                while (($key, $value) = each %access) {

                if ( $value !~ /RELAYCLIENT/ ) {
                        next;
                }

                # (almost) same as _read_hash_db
        if    ($key =~ 
/^\s*(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\s*$/) { 
$trusted{"$1.$2.$3.$4"} = 32; }
        elsif ($key =~ 
/^\s*(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.?\s*$/)         { 
$trusted{"$1.$2.$3.0"} = 24; }
        elsif ($key =~ 
/^\s*(\d{1,3})\.(\d{1,3})\.?\s*$/)                    { 
$trusted{"$1.$2.0.0"} = 16; }
        elsif ($key =~ 
/^\s*(\d{1,3})\.?\s*$/)                               { 
$trusted{"$1.0.0.0"} = 8; }
        else  { dbg("config: could not parse POPAuth database pair: 
'$key' => '$value', skipping"); }
    }

    dbg("config: untie-ing DB file $path");
    untie %access;

  } else {
    dbg("config: failed to tie DB");
    $self->{failed} = 1;
    return (undef, %trusted);
  }

  my $size = keys %trusted;
  return ($size, %trusted);
}