This is the second part of HowTo run ClamAV Anti Virus on a low memory system - and you chose the Courier maildrop based system. Please make sure that you understood and accepted the problems and limitations of this approach before starting.
After installing ClamAV we'll continue to...
mailbox_command = /usr/bin/maildrop local_destination_concurrency_limit=1 |
#!/bin/sh # avti-virus filter through maildrop exception { xfilter "/usr/local/bin/clamscanwrap" } |
include "/etc/maildroprc" |
#!/bin/sh ALERTMAIL="root@localhost" TMPFILE=/tmp/clamscan.$$ cat - > ${TMPFILE}.msg mkdir ${TMPFILE}.dir chmod go+r ${TMPFILE}.* /usr/bin/clamscan --quiet\ --no-summary \ --tempdir=${TMPFILE}.dir \ --recursive --max-files=500 --max-space=500M \ --unzip=/usr/bin/unzip --jar=/usr/bin/unzip \ --tar=/bin/tar --tgz=/bin/tar \ --log=${TMPFILE}.log \ ${TMPFILE}.msg typeset -i RESULT=$? if [ $RESULT -gt 0 ]; then VIRUS=`fgrep FOUND ${TMPFILE}.log | cut -d " " -f 2` grep -e "^[0-z-]*: .*" ${TMPFILE}.msg > ${TMPFILE}.header echo "" > ${TMPFILE}.mail echo "" >> ${TMPFILE}.mail echo -n "Virusscanner " >> ${TMPFILE}.mail /usr/bin/clamscan -V 2>> ${TMPFILE}.mail echo -n " " >> ${TMPFILE}.mail grep -e "^From:" ${TMPFILE}.msg >> ${TMPFILE}.mail echo -n " " >> ${TMPFILE}.mail grep -e "^To:" ${TMPFILE}.msg >> ${TMPFILE}.mail echo -n " " >> ${TMPFILE}.mail grep -e "^Subject:" ${TMPFILE}.msg >> ${TMPFILE}.mail echo -n " " >> ${TMPFILE}.mail grep -e "^Date:" ${TMPFILE}.msg >> ${TMPFILE}.mail echo " " >> ${TMPFILE}.mail echo " " >> ${TMPFILE}.mail echo "--------------------------------------------" >> ${TMPFILE}.mail echo "Volle (deaktivierte) Header" >> ${TMPFILE}.mail echo "--------------------------------------------" >> ${TMPFILE}.mail cat ${TMPFILE}.header | awk '{ print ". " $0 }' >> ${TMPFILE}.mail # alert mail to sysadmin cat ${TMPFILE}.mail | mail -s "Virus $VIRUS gefunden" $ALERTMAIL # and now alert mail to recipient cat ${TMPFILE}.header | sed -e "s/^Subject: .*/Subject: Virus $VIRUS gefunden/" echo "" cat /usr/local/bin/clamscanwrap.txt cat ${TMPFILE}.mail else cat ${TMPFILE}.msg echo " " echo "-------------------------------------------------------------" echo -n "No virus detected by " /usr/bin/clamscan -V 2>&1 fi rm -rf ${TMPFILE}* # exit $RESULT exit 0 |
Enjoy!
Corrections and suggestions are heartly welcome!