Hello everyone,
I know this is drudging up an old thread; however, I actually answered my own question by writing my own code to accomplish this. I wanted to share it in case others could benefit from it. See below for a simple script that scans the mail store and removes any infected messages (this is a manual process that must be run either through SSH, a cron job, or something similar). I didn't throw in a bunch of variables so if your store is NOT in ~/store/0/ (as zimbra user) or if something doesn't match your particular configuration, then you will need to modify/adjust script as necessary.
This script will automatically bypass the virus store db (since we know there are viruses there) and any archive accounts assuming they end in .archive (just in case...users shouldn't have access anyway). It will also output the results to stdout (console screen, log file, etc).
I placed the following code in a file called virusremovestore.sh (give it +x with chmod) and in a particular folder where I keep all my scripts (e.g. you could mkdir cyberdeath in /opt/zimbra and place the file in there). You are free to place it wherever you'd like so long as it is accessible by the zimbra user.
Code:
#!/bin/bash
old_IFS=$IFS
echo "Freshening up the anti-virus definitions"
/opt/zimbra/clamav/bin/freshclam --config-file=/opt/zimbra/conf/freshclam.conf
echo "Scanning Mail Store for Viruses"
~/clamav/bin/clamscan --database ~/data/clamav/db/ --recursive=yes --infected ~/store/0/ | while IFS=/ read root opt zimbra store messagestore storeid msg folder messageid virusname found
do
uid=`mysql -NBe "select comment from zimbra.mailbox where id='$storeid'"`
msgid=`echo $messageid | cut -d'-' -f1`
if [[ "$uid" == *.archive ]]; then
echo "Archive: Did not remove message $msgid from $uid"
elif [[ "$uid" == *virus*quarantine* ]]; then
echo "Skipping message $msgid in virus quarantine"
else
zmmailbox -z -m $uid dm $msgid
echo "Found and removed infected message $msgid from $uid"
fi
done
IFS=$old_IFS On a final note, I wanted to mention that I still haven't implemented a new anti-virus solution that will directly integrate with Zimbra. However, I have spoken with a couple A/V vendors who say they are compatible with postfix (Symantec & Kaspersky).
If you have any questions or comments, please feel free.