diff -urN original/spamscanners/SpamAssassin.pm modified/spamscanners/SpamAssassin.pm --- original/spamscanners/SpamAssassin.pm 2005-12-30 16:16:05.000000000 -0500 +++ modified/spamscanners/SpamAssassin.pm 2005-12-30 16:58:32.000000000 -0500 @@ -139,7 +139,7 @@ my($missing) = Amavis::Boot::fetch_modules('PRE-COMPILE OPTIONAL MODULES', 0, @modules) if @modules; do_log(2, 'INFO: no optional modules: '.join(' ',@$missing)) - if ref $missing && @$missing; + if ref $missing and @$missing; } sub initializeSpamAssassin() { @@ -162,7 +162,7 @@ # $Mail::SpamAssassin::DEBUG->{pyzor}=-3; # $Mail::SpamAssassin::DEBUG->{bayes}=-3; # $Mail::SpamAssassin::DEBUG->{rulesrun}=4+64; - if ($sa_auto_whitelist && $self->sa_version() < 3) { + if ($sa_auto_whitelist and $self->sa_version() < 3) { do_log(1, "SpamControl: turning on SA auto-whitelisting (AWL)"); # create a factory for the persistent address list my($addrlstfactory) = Mail::SpamAssassin::DBBasedAddrList->new; @@ -204,7 +204,7 @@ my($fh) = $msginfo->mail_text; my($spam_level,$spam_status,$spam_report,$autolearn_status); my(@lines); my($hdr_edits) = $msginfo->header_edits; - if (!$hdr_edits) { + if (not $hdr_edits) { $hdr_edits = Amavis::Out::EditHeader->new; $msginfo->header_edits($hdr_edits); } @@ -215,8 +215,8 @@ join(",\n ",qquote_rfc2821_local(@{$msginfo->recips})))); my($fh) = $msginfo->mail_text; my($mbsl) = c('sa_mail_body_size_limit'); - if ( defined $mbsl && - ($msginfo->orig_body_size > $mbsl || + if ( defined $mbsl and + ($msginfo->orig_body_size > $mbsl or $msginfo->orig_header_size + 1 + $msginfo->orig_body_size > 5*1024 + $mbsl) ) { @@ -231,8 +231,8 @@ $dspam_fname = $msginfo->mail_tempdir . '/dspam.msg'; my($dspam_fh) = IO::File->new; # will receive output from DSPAM $dspam_fh->open($dspam_fname, O_CREAT|O_EXCL|O_WRONLY, 0640) - or die "Can't create file $dspam_fname: $!"; - $fh->seek(0,0) or die "Can't rewind mail file: $!"; + or die "Can't create file $dspam_fname: $ERRNO"; + $fh->seek(0,0) or die "Can't rewind mail file: $ERRNO"; my($proc_fh,$pid) = run_command('&'.fileno($fh), "&1", $dspam, qw(--stdout --deliver=spam,innocent --mode=tum --feature=chained,noise @@ -241,13 +241,13 @@ ); # --mode=teft # qw(--stdout --deliver-spam) # dspam < 3.0 # keep X-DSPAM-*, ignore other changes e.g. Content-Transfer-Encoding - my($all_local) = !grep { !lookup(0,$_,@{ca('local_domains_maps')}) } + my($all_local) = not grep { not lookup(0,$_,@{ca('local_domains_maps')}) } @{$msginfo->recips}; my($first_line); my($ln); # scan mail header from DSPAM - for (undef $!; defined($ln=$proc_fh->getline); undef $!) { - $dspam_fh->print($ln) or die "Can't write to $dspam_fname: $!"; - if (!defined($first_line)) + for (undef $ERRNO; defined($ln=$proc_fh->getline); undef $ERRNO) { + $dspam_fh->print($ln) or die "Can't write to $dspam_fname: $ERRNO"; + if (not defined($first_line)) { $first_line = $ln; do_log(5,"spam_scan: from DSPAM: $first_line") } last if $ln eq $eol; local($1,$2); @@ -260,30 +260,30 @@ $hdr_edits->append_header($hh,$hb) if $all_local; } } - defined $ln || $!==0 || $!==EAGAIN - or die "Error reading from DSPAM process: $!"; + defined $ln or $ERRNO==0 or $ERRNO==EAGAIN + or die "Error reading from DSPAM process: $ERRNO"; my($nbytes,$buff); while (($nbytes=$proc_fh->read($buff,16384)) > 0) { #copy body from DSPAM - $dspam_fh->print($buff) or die "Can't write to $dspam_fname: $!"; + $dspam_fh->print($buff) or die "Can't write to $dspam_fname: $ERRNO"; } - defined $nbytes or die "Error reading: $!"; - my($err); $proc_fh->close or $err = $!; my($retval) = retcode($?); - $dspam_fh->close or die "Error closing $dspam_fname: $!"; + defined $nbytes or die "Error reading: $ERRNO"; + my($err); $proc_fh->close or $err = $ERRNO; my($retval) = retcode($?); + $dspam_fh->close or die "Error closing $dspam_fname: $ERRNO"; do_log(-1,sprintf("WARN: DSPAM problem, %s, result=%s", exit_status_str($?,$err), $first_line) - ) if $retval || !defined $first_line; + ) if $retval or not defined $first_line; do_log(4,"spam_scan: DSPAM gave: $dspam_signature, $dspam_result"); section_time('DSPAM'); } # read mail into memory in preparation for SpamAssasin - $fh->seek(0,0) or die "Can't rewind mail file: $!"; + $fh->seek(0,0) or die "Can't rewind mail file: $ERRNO"; my($body_lines)=0; my($ln); - for (undef $!; defined($ln=<$fh>); undef $!) # header + for (undef $ERRNO; defined($ln=<$fh>); undef $ERRNO) # header { push(@lines,$ln); last if $ln eq $eol } - defined $ln || $!==0 or die "Error reading mail header: $!"; - for (undef $!; defined($ln=<$fh>); undef $!) # body + defined $ln or $ERRNO==0 or die "Error reading mail header: $ERRNO"; + for (undef $ERRNO; defined($ln=<$fh>); undef $ERRNO) # body { push(@lines,$ln); $body_lines++ } - defined $ln || $!==0 or die "Error reading mail body: $!"; + defined $ln or $ERRNO==0 or die "Error reading mail body: $ERRNO"; section_time('SA msg read'); my($sa_required, $sa_tests); @@ -345,32 +345,32 @@ section_time('SA check'); umask($saved_umask); # SA changes umask to 0077 prolong_timer('spam_scan_SA', $remaining_time); # restart the timer - if ($@ ne '') { # SA timed out? - chomp($@); - die "$@\n" if $@ ne "timed out"; + if ($EVAL_ERROR ne '') { # SA timed out? + chomp($EVAL_ERROR); + die "$EVAL_ERROR\n" if $EVAL_ERROR ne "timed out"; } $sa_tests =~ s/,\s*/,/g; $spam_status = "tests=[" . $sa_tests . "]"; add_entropy($spam_level,$sa_tests); - if ($dspam ne '' && defined $spam_level) { # DSPAM auto-learn + if ($dspam ne '' and defined $spam_level) { # DSPAM auto-learn my($eat,@options); @options = (qw(--stdout --mode=tum --user), $daemon_user); # --mode=teft - if ( $spam_level > 7.0 && $dspam_result eq 'Innocent') { + if ( $spam_level > 7.0 and $dspam_result eq 'Innocent') { $eat = 'SPAM'; push(@options, qw(--class=spam --source=error)); # @options = qw(--stdout --addspam); # dspam < 3.0 } - elsif ($spam_level < 0.5 && $dspam_result eq 'Spam') { + elsif ($spam_level < 0.5 and $dspam_result eq 'Spam') { $eat = 'HAM'; push(@options, qw(--class=innocent --source=error)); # @options = qw(--stdout --falsepositive); # dspam < 3.0 } - if (defined $eat && $dspam_signature ne '') { + if (defined $eat and $dspam_signature ne '') { do_log(2,"DSPAM learn $eat ($spam_level), $dspam_signature"); my($proc_fh,$pid) = run_command($dspam_fname, "&1", $dspam, @options); # consume remaining output to avoid broken pipe my($nbytes,$buff); while (($nbytes=$proc_fh->read($buff,4096)) > 0) { } - defined $nbytes or die "Error reading from DSPAM process: $!"; - my($err); $proc_fh->close or $err = $!; my($retval) = retcode($?); + defined $nbytes or die "Error reading from DSPAM process: $ERRNO"; + my($err); $proc_fh->close or $err = $ERRNO; my($retval) = retcode($?); # do_log(-1,"DSPAM learn $eat response:".$output) if $output ne ''; $retval==0 or die ("DSPAM learn $eat FAILED: ".exit_status_str($?,$err)); section_time('DSPAM learn'); @@ -380,7 +380,7 @@ if (defined $dspam_fname) { if (($spam_level > 5.0 ? 1 : 0) != ($dspam_result eq 'Spam' ? 1 : 0)) { do_log(2,"DSPAM: different opinions: $dspam_result, $spam_level") } - unlink($dspam_fname) or die "Can't delete file $dspam_fname: $!"; + unlink($dspam_fname) or die "Can't delete file $dspam_fname: $ERRNO"; } do_log(3,"spam_scan: hits=$spam_level $spam_status"); ($spam_level, $spam_status, $spam_report, $autolearn_status);