2006-05-31 22:54:03 +02:00
|
|
|
package Qpsmtpd::TcpServer::Prefork;
|
|
|
|
use Qpsmtpd::TcpServer;
|
|
|
|
use Qpsmtpd::SMTP::Prefork;
|
2006-11-22 17:30:37 +01:00
|
|
|
use Qpsmtpd::Constants;
|
2006-05-31 22:54:03 +02:00
|
|
|
|
|
|
|
@ISA = qw(Qpsmtpd::SMTP::Prefork Qpsmtpd::TcpServer);
|
|
|
|
|
|
|
|
my $first_0;
|
|
|
|
|
|
|
|
sub start_connection {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
#reset info
|
2007-09-26 09:02:15 +02:00
|
|
|
# $self->{_connection} = Qpsmtpd::Connection->new(); #reset connection
|
|
|
|
$self->reset_connection; #reset connection
|
2007-08-28 20:42:01 +02:00
|
|
|
$self->reset_transaction;
|
2006-11-22 17:30:37 +01:00
|
|
|
$self->SUPER::start_connection(@_);
|
2006-05-31 22:54:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub read_input {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $timeout =
|
|
|
|
$self->config('timeoutsmtpd') # qmail smtpd control file
|
|
|
|
|| $self->config('timeout') # qpsmtpd control file
|
|
|
|
|| 1200; # default value
|
|
|
|
|
|
|
|
alarm $timeout;
|
|
|
|
eval {
|
|
|
|
while (<STDIN>) {
|
|
|
|
alarm 0;
|
|
|
|
$_ =~ s/\r?\n$//s; # advanced chomp
|
2007-05-11 09:52:35 +02:00
|
|
|
$self->log(LOGINFO, "dispatching $_");
|
2006-05-31 22:54:03 +02:00
|
|
|
$self->connection->notes('original_string', $_);
|
2006-09-14 21:48:37 +02:00
|
|
|
defined $self->dispatch(split / +/, $_, 2)
|
2006-05-31 22:54:03 +02:00
|
|
|
or $self->respond(502, "command unrecognized: '$_'");
|
|
|
|
alarm $timeout;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if ($@ =~ /^disconnect_tcpserver/) {
|
|
|
|
die "disconnect_tcpserver";
|
|
|
|
} else {
|
|
|
|
die "died while reading from STDIN (probably broken sender) - $@";
|
|
|
|
}
|
|
|
|
alarm(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub respond {
|
|
|
|
my ($self, $code, @messages) = @_;
|
|
|
|
while (my $msg = shift @messages) {
|
|
|
|
my $line = $code . (@messages?"-":" ").$msg;
|
2007-05-11 09:52:35 +02:00
|
|
|
$self->log(LOGINFO, $line);
|
2006-05-31 22:54:03 +02:00
|
|
|
print "$line\r\n" or ($self->log(LOGERROR, "Could not print [$line]: $!"), return 0);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-11-22 17:30:37 +01:00
|
|
|
sub disconnect {
|
|
|
|
my $self = shift;
|
2007-05-11 09:52:35 +02:00
|
|
|
$self->log(LOGINFO,"click, disconnecting");
|
2006-11-22 17:30:37 +01:00
|
|
|
$self->SUPER::disconnect(@_);
|
|
|
|
$self->run_hooks("post-connection");
|
|
|
|
die "disconnect_tcpserver";
|
|
|
|
}
|
|
|
|
|
2006-05-31 22:54:03 +02:00
|
|
|
1;
|