Lines 82-87
Link Here
|
82 |
EX_PROTOCOL => 76, # remote error in protocol |
82 |
EX_PROTOCOL => 76, # remote error in protocol |
83 |
EX_NOPERM => 77, # permission denied |
83 |
EX_NOPERM => 77, # permission denied |
84 |
EX_CONFIG => 78, # configuration error |
84 |
EX_CONFIG => 78, # configuration error |
|
|
85 |
EX_TIMEOUT => 79, # read timeout |
85 |
); |
86 |
); |
86 |
|
87 |
|
87 |
*dbg = \&Mail::SpamAssassin::dbg; |
88 |
*dbg = \&Mail::SpamAssassin::dbg; |
Lines 189-194
Link Here
|
189 |
'ssl' => \$opt{'ssl'}, |
190 |
'ssl' => \$opt{'ssl'}, |
190 |
'syslog-socket=s' => \$opt{'syslog-socket'}, |
191 |
'syslog-socket=s' => \$opt{'syslog-socket'}, |
191 |
'syslog|s=s' => \$opt{'syslog'}, |
192 |
'syslog|s=s' => \$opt{'syslog'}, |
|
|
193 |
'timeout-tcp|T=i' => \$opt{'timeout-tcp'}, |
194 |
'timeout-child|t=i' => \$opt{'timeout-child'}, |
192 |
'user-config' => \$opt{'user-config'}, |
195 |
'user-config' => \$opt{'user-config'}, |
193 |
'username|u=s' => \$opt{'username'}, |
196 |
'username|u=s' => \$opt{'username'}, |
194 |
'version|V' => \$opt{'version'}, |
197 |
'version|V' => \$opt{'version'}, |
Lines 515-520
Link Here
|
515 |
|
518 |
|
516 |
my $client; # used for the client connection ... |
519 |
my $client; # used for the client connection ... |
517 |
my $childlimit; # max number of kids allowed |
520 |
my $childlimit; # max number of kids allowed |
|
|
521 |
my $timeout_tcp; # socket timeout (connect->headers), 0=no timeout |
522 |
my $timeout_child; # processing timeout (headers->finish), 0=no timeout |
518 |
my $clients_per_child; # number of clients each child should process |
523 |
my $clients_per_child; # number of clients each child should process |
519 |
my %children = (); # current children |
524 |
my %children = (); # current children |
520 |
|
525 |
|
Lines 532-540
Link Here
|
532 |
$clients_per_child = undef if ( $clients_per_child < 1 ); |
537 |
$clients_per_child = undef if ( $clients_per_child < 1 ); |
533 |
} |
538 |
} |
534 |
|
539 |
|
|
|
540 |
if (defined $opt{'timeout-tcp'}) { |
541 |
$timeout_tcp = $opt{'timeout-tcp'}; |
542 |
$timeout_tcp = undef if ($timeout_tcp < 1); |
543 |
} |
544 |
|
545 |
if (defined $opt{'timeout_child'}) { |
546 |
$timeout_child = $opt{'timeout_child'}; |
547 |
$timeout_child = undef if ($timeout_child < 1); |
548 |
} |
549 |
|
535 |
# Set some "sane" limits for defaults |
550 |
# Set some "sane" limits for defaults |
536 |
$childlimit ||= 5; |
551 |
$childlimit ||= 5; |
537 |
$clients_per_child ||= 200; |
552 |
$clients_per_child ||= 200; |
|
|
553 |
$timeout_child ||= 300; |
554 |
$timeout_tcp ||= 30; |
538 |
|
555 |
|
539 |
# ensure scaling parameters are logical |
556 |
# ensure scaling parameters are logical |
540 |
if ($opt{'min-children'} < 1) { |
557 |
if ($opt{'min-children'} < 1) { |
Lines 552-558
Link Here
|
552 |
$opt{'max-spare'} = $opt{'min-spare'}+1; |
569 |
$opt{'max-spare'} = $opt{'min-spare'}+1; |
553 |
} |
570 |
} |
554 |
|
571 |
|
555 |
|
|
|
556 |
my $dontcopy = 1; |
572 |
my $dontcopy = 1; |
557 |
if ( $opt{'create-prefs'} ) { $dontcopy = 0; } |
573 |
if ( $opt{'create-prefs'} ) { $dontcopy = 0; } |
558 |
|
574 |
|
Lines 701-711
Link Here
|
701 |
} |
717 |
} |
702 |
} |
718 |
} |
703 |
|
719 |
|
704 |
# sanity check! |
|
|
705 |
if (!-S $path) { |
706 |
die "Could not find newly-created UNIX socket (2) on $path: $! ($@)\n"; |
707 |
} |
708 |
|
709 |
if (!chmod $mode, $path) { # make sure everybody can talk to it |
720 |
if (!chmod $mode, $path) { # make sure everybody can talk to it |
710 |
die "Could not chmod $path to $mode: $! ($@)"; |
721 |
die "Could not chmod $path to $mode: $! ($@)"; |
711 |
} |
722 |
} |
Lines 1053-1061
Link Here
|
1053 |
} |
1064 |
} |
1054 |
} |
1065 |
} |
1055 |
|
1066 |
|
1056 |
# send the request to the child process |
1067 |
local ($_); |
1057 |
local ($_) = $client->getline; |
1068 |
eval { |
|
|
1069 |
Mail::SpamAssassin::Util::trap_sigalrm_fully(sub { |
1070 |
die "tcp timeout"; |
1071 |
}); |
1072 |
alarm $timeout_tcp if ($timeout_tcp); |
1073 |
# send the request to the child process |
1074 |
$_ = $client->getline; |
1075 |
}; |
1076 |
alarm 0; |
1058 |
|
1077 |
|
|
|
1078 |
if ($@) { |
1079 |
service_timeout("($timeout_tcp second socket timeout reading input from client)"); |
1080 |
$client->close; |
1081 |
return 0; |
1082 |
} |
1083 |
|
1059 |
if ( !defined $_ ) { |
1084 |
if ( !defined $_ ) { |
1060 |
protocol_error("(closed before headers)"); |
1085 |
protocol_error("(closed before headers)"); |
1061 |
$client->close; |
1086 |
$client->close; |
Lines 1080-1086
Link Here
|
1080 |
# message that we need to filter. |
1105 |
# message that we need to filter. |
1081 |
|
1106 |
|
1082 |
elsif (/(PROCESS|CHECK|SYMBOLS|REPORT|REPORT_IFSPAM) SPAMC\/(.*)/) { |
1107 |
elsif (/(PROCESS|CHECK|SYMBOLS|REPORT|REPORT_IFSPAM) SPAMC\/(.*)/) { |
1083 |
check( $1, $2, $start, $remote_hostname, $remote_hostaddr ); |
1108 |
my $method = $1; |
|
|
1109 |
eval { |
1110 |
Mail::SpamAssassin::Util::trap_sigalrm_fully(sub { |
1111 |
die "child processing timeout"; |
1112 |
}); |
1113 |
alarm $timeout_child if ($timeout_child); |
1114 |
check($method, $2, $start, $remote_hostname, $remote_hostaddr); |
1115 |
}; |
1116 |
alarm 0; |
1117 |
|
1118 |
if ($@) { |
1119 |
service_timeout("($timeout_child second timeout while trying to $method)"); |
1120 |
$client->close(); |
1121 |
return 1; |
1122 |
} |
1084 |
} |
1123 |
} |
1085 |
|
1124 |
|
1086 |
# Looks like a client is just seeing if we're alive. |
1125 |
# Looks like a client is just seeing if we're alive. |
Lines 1437-1442
Link Here
|
1437 |
logmsg("service unavailable: $err"); |
1476 |
logmsg("service unavailable: $err"); |
1438 |
} |
1477 |
} |
1439 |
|
1478 |
|
|
|
1479 |
sub service_timeout { |
1480 |
my ($err) = @_; |
1481 |
my $resp = "EX_TIMEOUT"; |
1482 |
print $client "SPAMD/1.0 $resphash{$resp} Timeout: $err\r\n"; |
1483 |
logmsg("timeout: $err"); |
1484 |
} |
1485 |
|
1440 |
########################################################################### |
1486 |
########################################################################### |
1441 |
|
1487 |
|
1442 |
sub auth_ident { |
1488 |
sub auth_ident { |
Lines 2379-2384
Link Here
|
2379 |
versions 3.0.0 and 3.0.1 will be used instead, where all processes receive an |
2425 |
versions 3.0.0 and 3.0.1 will be used instead, where all processes receive an |
2380 |
equal load and no scaling takes place. |
2426 |
equal load and no scaling takes place. |
2381 |
|
2427 |
|
|
|
2428 |
=item B<--timeout-tcp>=I<number> |
2429 |
|
2430 |
This option specifies the number of seconds to wait for headers from a |
2431 |
client (spamc) before closing the connection. The minimum value is C<1>, |
2432 |
the default value is C<30>, and a value of C<0> will disable socket |
2433 |
timeouts completely. |
2434 |
|
2435 |
=item B<--timeout-child>=I<number> |
2436 |
|
2437 |
This option specifies the number of seconds to wait for a spamd child to |
2438 |
to process or check a message. The minimum value is C<1>, the default |
2439 |
value is C<300>, and a value of C<0> will disable child timeouts completely. |
2440 |
|
2382 |
=item B<-H> I<directory>, B<--helper-home-dir>=I<directory> |
2441 |
=item B<-H> I<directory>, B<--helper-home-dir>=I<directory> |
2383 |
|
2442 |
|
2384 |
Specify that external programs such as Razor, DCC, and Pyzor should have |
2443 |
Specify that external programs such as Razor, DCC, and Pyzor should have |