3 messages in net.sourceforge.lists.courier-usersRe: [courier-users] Virus scanning wi...
FromSent OnAttachments
Dan JohanssonApr 11, 2004 5:43 am 
Martijn LievaartApr 11, 2004 8:54 am 
Grzegorz JanoszkaApr 12, 2004 12:52 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [courier-users] Virus scanning with CourierActions...
From:Martijn Lievaart (m@rtij.nl)
Date:Apr 11, 2004 8:54:40 am
List:net.sourceforge.lists.courier-users

Dan Johansson wrote:

Hi,

Are there someone out there in courier-land who won't mind sharing some experiences with virus scanning with courier?

I've been playing around with amavisd-new and ClamAV some time now and have not been able to get it to run to my satisfaction.

What I want to do is to scan every mail (local & SMTP) that hits my server and only put in X-headers (X-Virus-Scanned: & X-Amavis-Alert:) with the status of the message - NO quarantine is needed.

So if someone has a cookbook for this type of setup I would be grateful if you didn't mind to share it.

I don't use amavis, just a simple script that can be used as an xfilter:

/etc/courier/maildroprc: xfilter "/usr/local/sbin/scanmail"

/usr/local/sbin/scanmail: #!/usr/bin/perl -w

use strict;

mkdir "/tmp/mailscan", 0777;

umask 077; my $tmpnam = "/tmp/mailscan/$$";

my $fh; open $fh, ">$tmpnam" or do { `logger -t scanmail "cannot open $tmpnam"`; exit 1; # not much we can do, defer all mail };

my @lines = <>; print $fh @lines; close $fh;

my @result = `/usr/bin/clamdscan --disable-summary --stdout $tmpnam`; my $rc=($?>>8); unlink $tmpnam or `logger -t scanmail "cannot unlink $tmpnam"`;

my @extra_headers=("X-Scanned: Yup\n"); #print "rc=$rc\n", @result;

map { s/^ *//; push @extra_headers, "X-Virus: $_\n"; } grep /FOUND/, @result;

my $headers=1; for my $line (@lines) { if ($headers and $line eq "\n") { for (@extra_headers) { print; } $headers=0; } print $line; } exit 0;