Lines 349-354
Link Here
|
349 |
|
349 |
|
350 |
########################################################################### |
350 |
########################################################################### |
351 |
|
351 |
|
|
|
352 |
setup_sig_handlers(); |
353 |
|
352 |
# Everything below here needs ArchiveIterator ... |
354 |
# Everything below here needs ArchiveIterator ... |
353 |
my $iter = new Mail::SpamAssassin::ArchiveIterator( |
355 |
my $iter = new Mail::SpamAssassin::ArchiveIterator( |
354 |
{ |
356 |
{ |
Lines 409-418
Link Here
|
409 |
|
411 |
|
410 |
########################################################################### |
412 |
########################################################################### |
411 |
|
413 |
|
|
|
414 |
my $mail; # global, so signal handler can clean it up; bug 5626 |
415 |
|
412 |
# make sure it only returns false values so that result_sub() isn't called... |
416 |
# make sure it only returns false values so that result_sub() isn't called... |
413 |
sub wanted { |
417 |
sub wanted { |
414 |
my $dataref = $_[3]; |
418 |
my $dataref = $_[3]; |
415 |
my $mail = $spamtest->parse($dataref); |
419 |
$mail = $spamtest->parse($dataref); |
416 |
$count++; |
420 |
$count++; |
417 |
|
421 |
|
418 |
# This is a short cut -- doing white/black-list? Do it and return quickly. |
422 |
# This is a short cut -- doing white/black-list? Do it and return quickly. |
Lines 431-436
Link Here
|
431 |
} |
435 |
} |
432 |
|
436 |
|
433 |
$mail->finish(); |
437 |
$mail->finish(); |
|
|
438 |
$mail = undef; |
434 |
return 1; |
439 |
return 1; |
435 |
} |
440 |
} |
436 |
|
441 |
|
Lines 441-446
Link Here
|
441 |
if ( !$opt{'test-mode'} ) { |
446 |
if ( !$opt{'test-mode'} ) { |
442 |
print $spamtest->remove_spamassassin_markup ($mail); |
447 |
print $spamtest->remove_spamassassin_markup ($mail); |
443 |
$mail->finish(); |
448 |
$mail->finish(); |
|
|
449 |
$mail = undef; |
444 |
return 1; |
450 |
return 1; |
445 |
} |
451 |
} |
446 |
else { |
452 |
else { |
Lines 451-456
Link Here
|
451 |
# |
457 |
# |
452 |
my $new_mail = |
458 |
my $new_mail = |
453 |
$spamtest->parse( $spamtest->remove_spamassassin_markup($mail) ); |
459 |
$spamtest->parse( $spamtest->remove_spamassassin_markup($mail) ); |
|
|
460 |
|
454 |
$mail->finish(); |
461 |
$mail->finish(); |
455 |
$mail = $new_mail; |
462 |
$mail = $new_mail; |
456 |
} |
463 |
} |
Lines 463-475
Link Here
|
463 |
my $new_mail = |
470 |
my $new_mail = |
464 |
$spamtest->parse( $spamtest->remove_spamassassin_markup($mail) ); |
471 |
$spamtest->parse( $spamtest->remove_spamassassin_markup($mail) ); |
465 |
$mail->finish(); |
472 |
$mail->finish(); |
|
|
473 |
$mail = $new_mail; |
466 |
|
474 |
|
467 |
my $failed; |
475 |
my $failed; |
468 |
if ( $opt{'report'} && !$spamtest->report_as_spam($new_mail) ) { |
476 |
if ( $opt{'report'} && !$spamtest->report_as_spam($mail) ) { |
469 |
$failed = 'report'; |
477 |
$failed = 'report'; |
470 |
} |
478 |
} |
471 |
|
479 |
|
472 |
if ( $opt{'revoke'} && !$spamtest->revoke_as_spam($new_mail) ) { |
480 |
if ( $opt{'revoke'} && !$spamtest->revoke_as_spam($mail) ) { |
473 |
$failed = 'revoke'; |
481 |
$failed = 'revoke'; |
474 |
} |
482 |
} |
475 |
|
483 |
|
Lines 478-484
Link Here
|
478 |
warn "spamassassin: for more information, re-run with -D option to see debug output\n"; |
486 |
warn "spamassassin: for more information, re-run with -D option to see debug output\n"; |
479 |
} |
487 |
} |
480 |
|
488 |
|
481 |
$new_mail->finish(); |
489 |
$mail->finish(); |
|
|
490 |
$mail = undef; |
482 |
return 1; |
491 |
return 1; |
483 |
} |
492 |
} |
484 |
|
493 |
|
Lines 499-509
Link Here
|
499 |
|
508 |
|
500 |
# clean up after ourselves |
509 |
# clean up after ourselves |
501 |
$mail->finish(); |
510 |
$mail->finish(); |
|
|
511 |
$mail = undef; |
512 |
|
502 |
$status->finish(); |
513 |
$status->finish(); |
503 |
|
514 |
|
504 |
return 1; |
515 |
return 1; |
505 |
} |
516 |
} |
506 |
|
517 |
|
|
|
518 |
########################################################################### |
519 |
|
520 |
sub setup_sig_handlers { |
521 |
$SIG{HUP} = \&kill_handler; |
522 |
$SIG{INT} = \&kill_handler; |
523 |
$SIG{TERM} = \&kill_handler; |
524 |
$SIG{PIPE} = \&kill_handler; |
525 |
} |
526 |
|
527 |
sub kill_handler { |
528 |
my ($sig) = @_; |
529 |
info("spamassassin: killed by SIG$sig"); |
530 |
if ($mail) { |
531 |
$mail->finish(); # bug 5626: remove temp files etc. |
532 |
$mail = undef; |
533 |
} |
534 |
exit 0; |
535 |
} |
536 |
|
507 |
# --------------------------------------------------------------------------- |
537 |
# --------------------------------------------------------------------------- |
508 |
|
538 |
|
509 |
=cut |
539 |
=cut |