qpsmtpd/lib/Qpsmtpd/SMTP/Prefork.pm
Hanno Hecker 9c91bb04e6 unrecognized command fix for http://code.google.com/p/smtpd/issues/detail?id=16
- the reporters poposed fix would have caused two messages for the client on
  return(DENY, ...) or a really unknown command.


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@772 958fd67b-6ff1-0310-b445-bb7760255be9
2007-08-19 06:49:42 +00:00

31 lines
713 B
Perl

package Qpsmtpd::SMTP::Prefork;
use Qpsmtpd::SMTP;
use Qpsmtpd::Constants;
@ISA = qw(Qpsmtpd::SMTP);
sub dispatch {
my $self = shift;
my ($cmd) = lc shift;
$self->{_counter}++;
if ($cmd !~ /^(\w{1,12})$/ or !exists $self->{_commands}->{$1}) {
$self->run_hooks("unrecognized_command", $cmd, @_);
return 1;
}
$cmd = $1;
if (1 or $self->{_commands}->{$cmd} and $self->can($cmd)) {
my ($result) = eval { $self->$cmd(@_) };
if ($@ =~ /^disconnect_tcpserver/) {
die "disconnect_tcpserver";
} elsif ($@) {
$self->log(LOGERROR, "XX: $@") if $@;
}
return $result if defined $result;
return $self->fault("command '$cmd' failed unexpectedly");
}
return;
}