added p0f support to greylist plugin

- these changes are in the previous TCPLOCAL patch. Documented here.
added p0f config option
added POD docs to explain usage
modified $dbdir selection logic. The previous logic failed when QPHOME was
 not selected (as is the case when tests are being run).
Added '.' as the dir of last resort for $dbdir selection (others $EMPTY/dir
 dumped greylisting database in / )

  - These changes are included in this patch -
Added t/plugin_tests/greylisting, with greylist logic testing (tests are
 disabled by default, as greylisting is disabled in config.sample/plugins)
Added example entry in config.sample/plugins

Signed-off-by: Robert <rspier@pobox.com>
This commit is contained in:
Matt Simerson 2010-05-11 01:31:52 -04:00 committed by Robert
parent cc2d8ccca6
commit b81d464c87
2 changed files with 112 additions and 0 deletions

View File

@ -34,6 +34,7 @@ check_badrcptto
check_spamhelo
# sender_permitted_from
# greylisting p0f genre,windows
auth/auth_flat_file
auth/authdeny

111
t/plugin_tests/greylisting Normal file
View File

@ -0,0 +1,111 @@
use Qpsmtpd::Address;
my $test_email = 'user@example.com';
my $address = Qpsmtpd::Address->new( "<$test_email>" );
my @greydbs = qw( denysoft_greylist.dbm denysoft_greylist.dbm.lock );
foreach ( @greydbs ) {
unlink $_ if -f $_;
};
sub register_tests {
my $self = shift;
$self->register_test("test_greylist_p0f_genre_miss", 1);
$self->register_test("test_greylist_p0f_genre_hit", 1);
$self->register_test("test_greylist_p0f_distance_hit", 1);
$self->register_test("test_greylist_p0f_distance_miss", 1);
$self->register_test("test_greylist_p0f_link_hit", 1);
$self->register_test("test_greylist_p0f_link_miss", 1);
$self->register_test("test_greylist_p0f_uptime_hit", 1);
$self->register_test("test_greylist_p0f_uptime_miss", 1);
}
sub test_greylist_p0f_genre_miss {
my $self = shift;
$self->{_greylist_config}{'p0f'} = 'genre,Linux';
$self->connection->notes('p0f'=> { genre => 'windows', link => 'dsl' } );
my $r = $self->rcpt_handler( $self->qp->transaction );
ok( $r == 909, 'p0f genre miss');
}
sub test_greylist_p0f_genre_hit {
my $self = shift;
$self->{_greylist_config}{'p0f'} = 'genre,Windows';
$self->connection->notes('p0f'=> { genre => 'windows', link => 'dsl' } );
$self->qp->transaction->sender( $address );
my $r = $self->rcpt_handler( $self->qp->transaction );
ok( $r eq 'This mail is temporarily denied', 'p0f genre hit');
}
sub test_greylist_p0f_distance_hit {
my $self = shift;
$self->{_greylist_config}{'p0f'} = 'distance,8';
$self->connection->notes('p0f'=> { distance=>9 } );
$self->qp->transaction->sender( $address );
my $r = $self->rcpt_handler( $self->qp->transaction );
ok( $r eq 'This mail is temporarily denied', 'p0f distance hit');
}
sub test_greylist_p0f_distance_miss {
my $self = shift;
$self->{_greylist_config}{'p0f'} = 'distance,8';
$self->connection->notes('p0f'=> { distance=>7 } );
$self->qp->transaction->sender( $address );
my $r = $self->rcpt_handler( $self->qp->transaction );
ok( $r == 909, 'p0f distance miss');
}
sub test_greylist_p0f_link_hit {
my $self = shift;
$self->{_greylist_config}{'p0f'} = 'link,dsl';
$self->connection->notes('p0f'=> { link=>'DSL' } );
$self->qp->transaction->sender( $address );
my $r = $self->rcpt_handler( $self->qp->transaction );
ok( $r eq 'This mail is temporarily denied', 'p0f link hit');
}
sub test_greylist_p0f_link_miss {
my $self = shift;
$self->{_greylist_config}{'p0f'} = 'link,dsl';
$self->connection->notes('p0f'=> { link=>'Ethernet' } );
$self->qp->transaction->sender( $address );
my $r = $self->rcpt_handler( $self->qp->transaction );
ok( $r == 909, 'p0f link miss');
}
sub test_greylist_p0f_uptime_hit {
my $self = shift;
$self->{_greylist_config}{'p0f'} = 'uptime,100';
$self->connection->notes('p0f'=> { uptime=> 99 } );
$self->qp->transaction->sender( $address );
my $r = $self->rcpt_handler( $self->qp->transaction );
ok( $r eq 'This mail is temporarily denied', 'p0f uptime hit');
}
sub test_greylist_p0f_uptime_miss {
my $self = shift;
$self->{_greylist_config}{'p0f'} = 'uptime,100';
$self->connection->notes('p0f'=> { uptime=>500 } );
$self->qp->transaction->sender( $address );
my $r = $self->rcpt_handler( $self->qp->transaction );
ok( $r == 909, 'p0f uptime miss');
}