From 22ca786bac0ee5985f9ba333c5c0d5510297b3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Tue, 15 Apr 2003 17:01:43 +0000 Subject: [PATCH] check_earlytalker plugin. Deny the connection if the client talks before we show our SMTP banner. (From Devin Carraway) Patch Qpsmtpd::SMTP to allow connect plugins to give DENY and DENYSOFT return codes. Based on patch from Devin Carraway. git-svn-id: https://svn.perl.org/qpsmtpd/trunk@133 958fd67b-6ff1-0310-b445-bb7760255be9 --- CREDITS | 1 + Changes | 6 ++++++ config.sample/plugins | 3 +++ lib/Qpsmtpd/SMTP.pm | 14 +++++++++++++- lib/Qpsmtpd/TcpServer.pm | 5 ++++- 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CREDITS b/CREDITS index 682cd18..f852099 100644 --- a/CREDITS +++ b/CREDITS @@ -5,6 +5,7 @@ check_badmailfrom and check_mailrcptto plugins. Devin Carraway : Patch to not accept half mails if the connection gets dropped at the wrong moment. Support and enable taint checking. MAIL FROM host dns check configurable. HELO hook. +initial earlytalker plugin. Andrew Pam : fixing the maximum message size (databytes) stuff. diff --git a/Changes b/Changes index fb9191a..3144b11 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ 0.26-dev + check_earlytalker plugin. Deny the connection if the client talks + before we show our SMTP banner. (From Devin Carraway) + + Patch Qpsmtpd::SMTP to allow connect plugins to give DENY and + DENYSOFT return codes. Based on patch from Devin Carraway. + Support morercpthosts.cdb config now takes an extra "type" parameter. If it's "map" then a diff --git a/config.sample/plugins b/config.sample/plugins index 63752fc..90a48d6 100644 --- a/config.sample/plugins +++ b/config.sample/plugins @@ -7,7 +7,10 @@ # http_config http://localhost/~smtpd/config/ http://www.example.com/smtp.pl?config= quit_fortune + +#check_earlytalker require_resolvable_fromhost + rhsbl dnsbl check_badmailfrom diff --git a/lib/Qpsmtpd/SMTP.pm b/lib/Qpsmtpd/SMTP.pm index d9a3105..2fd1952 100644 --- a/lib/Qpsmtpd/SMTP.pm +++ b/lib/Qpsmtpd/SMTP.pm @@ -73,9 +73,21 @@ sub start_conversation { # this should maybe be called something else than "connect", see # lib/Qpsmtpd/TcpServer.pm for more confusion. my ($rc, $msg) = $self->run_hooks("connect"); - if ($rc != DONE) { + if ($rc == DENY) { + $self->respond(550, ($msg || 'Connection from you denied, bye bye.')); + return $rc; + } + elsif ($rc == DENYSOFT) { + $self->respond(450, ($msg || 'Connection from you temporarily denied, bye bye.')); + return $rc; + } + elsif ($rc == DONE) { + return $rc; + } + elsif ($rc != DONE) { $self->respond(220, $self->config('me') ." ESMTP qpsmtpd " . $self->version ." ready; send us your mail, but not your spam."); + return DONE; } } diff --git a/lib/Qpsmtpd/TcpServer.pm b/lib/Qpsmtpd/TcpServer.pm index d1da3dd..9ff6eb8 100644 --- a/lib/Qpsmtpd/TcpServer.pm +++ b/lib/Qpsmtpd/TcpServer.pm @@ -1,5 +1,7 @@ package Qpsmtpd::TcpServer; use Qpsmtpd::SMTP; +use Qpsmtpd::Constants; + @ISA = qw(Qpsmtpd::SMTP); use strict; @@ -25,7 +27,8 @@ sub run { # should be somewhere in Qpsmtpd.pm and not here... $self->load_plugins; - $self->start_conversation; + my $rc = $self->start_conversation; + return if $rc != DONE; # this should really be the loop and read_input should just get one line; I think