test sircam block. (should be moved to external "filter")
fix bug with malformed rcpt to: commands. git-svn-id: https://svn.perl.org/qpsmtpd/trunk@3 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
615c00ea97
commit
0664a76dc3
9
qpsmtpd
9
qpsmtpd
@ -146,6 +146,7 @@ sub rcpt {
|
|||||||
return respond(501, "syntax error in parameters") unless $_[0] =~ m/^to:/i;
|
return respond(501, "syntax error in parameters") unless $_[0] =~ m/^to:/i;
|
||||||
return(503, "Use MAIL before RCPT") unless $state{transaction}->{from};
|
return(503, "Use MAIL before RCPT") unless $state{transaction}->{from};
|
||||||
my ($rcpt) = ($_[0] =~ m/to:(.*)/i)[0];
|
my ($rcpt) = ($_[0] =~ m/to:(.*)/i)[0];
|
||||||
|
$rcpt = $_[1] unless $rcpt;
|
||||||
$rcpt = (Mail::Address->parse($rcpt))[0];
|
$rcpt = (Mail::Address->parse($rcpt))[0];
|
||||||
return respond(501, "could not parse recipient") unless $rcpt;
|
return respond(501, "could not parse recipient") unless $rcpt;
|
||||||
return respond(550, "will not relay for ". $rcpt->host) unless check_relay($rcpt->host);
|
return respond(550, "will not relay for ". $rcpt->host) unless check_relay($rcpt->host);
|
||||||
@ -161,6 +162,8 @@ sub data {
|
|||||||
my $size = 0;
|
my $size = 0;
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
my $max_size = get_config('databytes') || 0;
|
my $max_size = get_config('databytes') || 0;
|
||||||
|
my $blocked = "";
|
||||||
|
my $header = 1;
|
||||||
while (<STDIN>) {
|
while (<STDIN>) {
|
||||||
last if $_ eq ".\r\n";
|
last if $_ eq ".\r\n";
|
||||||
$i++;
|
$i++;
|
||||||
@ -168,6 +171,11 @@ sub data {
|
|||||||
if $_ eq ".\n";
|
if $_ eq ".\n";
|
||||||
unless ($max_size and $size > $max_size) {
|
unless ($max_size and $size > $max_size) {
|
||||||
s/\r\n$/\n/;
|
s/\r\n$/\n/;
|
||||||
|
$header = 0 if $header and m/^\s*$/;
|
||||||
|
$blocked = "Your mail looks too much like that SirCam nonsense, please go away"
|
||||||
|
if $header
|
||||||
|
and $state{transaction}->{from}->format eq "<>"
|
||||||
|
and $_ eq "Content-Disposition: Multipart message";
|
||||||
$buffer .= $_;
|
$buffer .= $_;
|
||||||
$size += length $_;
|
$size += length $_;
|
||||||
}
|
}
|
||||||
@ -176,6 +184,7 @@ sub data {
|
|||||||
alarm $config{timeout};
|
alarm $config{timeout};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
respond(550, $blocked),return 1 if $blocked;
|
||||||
respond(552, "Message too big!"),return 1 if $max_size and $size > $max_size;
|
respond(552, "Message too big!"),return 1 if $max_size and $size > $max_size;
|
||||||
|
|
||||||
# these bits inspired by Peter Samuels "qmail-queue wrapper"
|
# these bits inspired by Peter Samuels "qmail-queue wrapper"
|
||||||
|
Loading…
Reference in New Issue
Block a user