added ClamAV version to the X-Virus-Checked header

Signed-off-by: Robert <rspier@pobox.com>
This commit is contained in:
Matt Simerson 2010-05-02 01:48:05 -04:00 committed by Robert
parent 93c1a238e8
commit 68ecedd1ac

View File

@ -1,5 +1,4 @@
#!/usr/bin/perl -w #!/usr/bin/perl -w
# $Id$
=head1 NAME =head1 NAME
@ -111,6 +110,7 @@ use warnings;
sub register { sub register {
my ( $self, $qp, @args ) = @_; my ( $self, $qp, @args ) = @_;
$self->log(LOGERROR, "Bad parameters for the clamdscan plugin") if @_ % 2;
%{ $self->{"_clamd"} } = @args; %{ $self->{"_clamd"} } = @args;
# Set some sensible defaults # Set some sensible defaults
@ -198,6 +198,9 @@ sub hook_data_post {
return DECLINED; return DECLINED;
} }
my @clamd_version = split(/\//, $clamd->version);
$self->{"_clamd"}->{'version'} = $clamd_version[0] || 'ClamAV';
my ( $path, $found ) = eval { $clamd->scan_path( $filename ) }; my ( $path, $found ) = eval { $clamd->scan_path( $filename ) };
if ($@) { if ($@) {
$self->log( LOGERROR, "Error scanning mail: $@" ); $self->log( LOGERROR, "Error scanning mail: $@" );
@ -218,11 +221,12 @@ sub hook_data_post {
} }
} }
else { else {
$transaction->header->add( 'X-Virus-Found', 'No' );
$self->log( LOGINFO, "ClamAV scan reports clean"); $self->log( LOGINFO, "ClamAV scan reports clean");
} }
$transaction->header->add( 'X-Virus-Checked', $transaction->header->add( 'X-Virus-Checked',
"Checked by ClamAV on " . $self->qp->config("me") ); "Checked by $self->{'_clamd'}->{'version'} on " . $self->qp->config("me") );
return (DECLINED); return (DECLINED);
} }