./MailFilter/Virusscan.pm


package MailFilter::Virusscan;

# scan for viruses
#
# based on:
# $Id: suggested-minimum-filter-for-windows-clients,v 1.81 2004/10/26 18:34:33 dfs Exp $

use strict;
use warnings;
use Mimedefang qw{
    :testing
    :action
    :logging
    :global
    message_contains_virus
};

#***********************************************************************
# %PROCEDURE: filter_begin
# %ARGUMENTS:
#  None
# %RETURNS:
#  Nothing
# %DESCRIPTION:
#  Called just before e-mail parts are processed
#***********************************************************************
sub filter_begin () {
    # Copy original message into work directory as an "mbox" file for
    # virus-scanning
    md_copy_orig_msg_to_work_dir_as_mbox_file();

    # Scan for viruses if any virus-scanners are installed
    my($code, $category, $action) = message_contains_virus();

    # Lower level of paranoia - only looks for actual viruses
    my $foundvirus = ($category eq "virus");

    # Higher level of paranoia - takes care of "suspicious" objects
    # $foundvirus ||= ($action eq "quarantine");

    if ($foundvirus) {
	md_graphdefang_log('virus', $VirusName, $RelayAddr);
	md_syslog('warning', "Discarding because of virus $VirusName");
	return action_discard();
    }

    if ($action eq "tempfail") {
	action_tempfail("Problem running virus-scanner");
	md_syslog('warning', "Problem running virus scanner: code=$code, category=$category, action=$action");
    }
}

# DO NOT delete the next line, or Perl will complain.
1;