Re: qmail-qfilter with clam and a script

Olivier Mueller <[email protected]>
Newsgroups gmane.comp.sysutils.bgware
Message-ID <[email protected]>
On Tue, 2005-07-05 at 04:13 -0400, Payal Rathod wrote:
> Does anyone have an idea on how do I run qmail-qfilter with clamav?
> Also, I would appreciate ideas on how do I joins these two programs.

Here some of my setup files: it's running fine since a few months, but
feedback about how it could be improved is of course welcome.

1) clamd up & running, no special settings in clamd.conf, but to debug
   I have these: 
	LogFile /var/log/clamd
	LogFileMaxSize 100M
	LogTime
	LogVerbose


2) at the beginning of /var/qmail/supervise/qmail-smtpd/run:

QMAILQUEUE="/var/qmail/qfilter/run-filter"
export QMAILQUEUE


3) /var/qmail/qfilter/run-filter:

#!/bin/sh
 
exec /usr/bin/qmail-qfilter \
 /var/qmail/qfilter/qfilter-clamdscan


4) /var/qmail/qfilter/qfilter-clamdscan:

   (create a /var/qmail/scantemp/ directory, and
    a /var/qmail/scanlog/virus maildir for the quarantine) 


#!/bin/sh
 
TMPFILE=`mktemp -d -q /var/qmail/scantemp/$$.XXXXXX`
chmod 0777 ${TMPFILE}
 
if [ $? -ne 0 ]; then
        echo after mktemp
>> /var/qmail/scantemp/run-scanner-clamdscan.log
        exit 1
fi
 
cat - >> ${TMPFILE}/msg
chmod 0777 ${TMPFILE}/msg
 
/usr/bin/clamdscan --quiet ${TMPFILE}
 
CLAMRET=$?
 
if [ $CLAMRET -eq 1 ]; then
        cp ${TMPFILE}/msg /var/qmail/scanlog/virus/new/`date +"%s.%j"`.$
$.virus
        rm -r ${TMPFILE}
        exit 31
fi

rm -r ${TMPFILE}
 




Voila, I guess that would be all... Otherwise feel free to ask. And many
thanks to all the people around who helped me before :)  
Todo: automatic quaratine cleanup (cron), logging of infected mails.

regards,
Olivier
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.