diff options
| author | fukachan <fukachan> | 2004-06-24 11:01:33 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-06-24 11:01:33 +0000 |
| commit | 5c0c6c644f18aa3a613d8d66b2f3dbdf66be4b62 (patch) | |
| tree | f40983b05f01a9d4a0045be89eacebdc24792b38 /fml | |
| parent | f157d82a780bebb5701bdcd6cbd3891aae3d58d7 (diff) | |
| download | fml8-5c0c6c644f18aa3a613d8d66b2f3dbdf66be4b62.tar.gz fml8-5c0c6c644f18aa3a613d8d66b2f3dbdf66be4b62.tar.bz2 fml8-5c0c6c644f18aa3a613d8d66b2f3dbdf66be4b62.zip | |
preliminary support of built-in clamav
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/FML/Filter/External/clamscan.pm | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/fml/lib/FML/Filter/External/clamscan.pm b/fml/lib/FML/Filter/External/clamscan.pm new file mode 100644 index 00000000..61c37392 --- /dev/null +++ b/fml/lib/FML/Filter/External/clamscan.pm @@ -0,0 +1,135 @@ +#-*- perl -*- +# +# Copyright (C) 2004 Ken'ichi Fukamachi +# All rights reserved. This program is free software; you can +# redistribute it and/or modify it under the same terms as Perl itself. +# +# $FML: @template.pm,v 1.8 2004/01/01 07:29:27 fukachan Exp $ +# + +package FML::Filter::External::clamscan; +use strict; +use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); +use Carp; + +=head1 NAME + +FML::Filter::External::clamscan - SpamAssassin interface. + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=head2 C<new()> + +=cut + + +# Descriptions: constructor. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: OBJ +sub new +{ + my ($self) = @_; + my ($type) = ref($self) || $self; + my $me = {}; + return bless $me, $type; +} + + +# Descriptions: check if the current message looks a spam. +# Arguments: OBJ($self) OBJ($curproc) +# Side Effects: none +# Return Value: NUM(1 or 0) (1 if spam) +sub process +{ + my ($self, $curproc) = @_; + my $config = $curproc->config(); + my $program = $config->{ path_clamscan } || ''; + + if ($program) { + if (-x $program) { + return $self->_check($curproc, $program); + } + else { + $curproc->logerror("$program not exists"); + } + } + else { + $curproc->logerror("path_clamscan undefined"); + } + + return 0; +} + + +# Descriptions: check the message through $program. +# Arguments: OBJ($self) OBJ($curproc) STR($program) +# Side Effects: none +# Return Value: NUM(1 or 0) (1 if virus) +sub _check +{ + my ($self, $curproc, $program) = @_; + my $opts = "--quiet --mbox" + + use FileHandle; + my $tmp_file = $curproc->temp_file_path(); + my $wh = new FileHandle "> $tmp_file"; + if (defined $wh) { + $wh->autoflush(1); + my $msg = $curproc->incoming_message(); + $msg->print($wh); + $wh->close(); + + unless (-f $tmp_file) { + return 0; + } + + my $status = 0; + system "$program $opts $tmp_file"; + if ($status = $?) { + if ($status == 1) { + my $r = "virus found by clamav"; + $curproc->logerror($r); + $curproc->filter_state_virus_checker_set_error($r); + } + else { + $curproc->logerror("bogofilter error: code=$?"); + return 0; + } + + return 1; + } + } + + return 0; +} + + +=head1 CODING STYLE + +See C<http://www.fml.org/software/FNF/> on fml coding style guide. + +=head1 AUTHOR + +Ken'ichi Fukamachi + +=head1 COPYRIGHT + +Copyright (C) 2004 Ken'ichi Fukamachi + +All rights reserved. This program is free software; you can +redistribute it and/or modify it under the same terms as Perl itself. + +=head1 HISTORY + +FML::Filter::External::clamscan appeared in fml8 mailing list driver package. +See C<http://www.fml.org/> for more details. + +=cut + + +1; |
