############################################################################## ## ## Procmail ruleset for cleaning mail using the Anomy Sanitizer. ## $Id: sanitizer.procmail,v 1.3 2004/05/13 13:37:25 bre Exp $ ## ## This recipie illustrates one reliable way to add headers (or perform other ## actions) based on the results of sanitizing. It also implements a basic ## quarantine ## ## Installation instructions: ## ## + Edit the variables near the top to match your system. ## ## + Install into your .procmailrc with a line like this: ## INCLUDERC=/path/to/sanitizer.procmail". ## ## + Test it! ## ## + If everything works, you will probably want to uncomment one of the ## cleanup rules near the end of the recipie, or comment out the rule ## near the top which makes backups of all incoming e-mail. ## ############################################################################## # Where do you keep Anomy? ANOMY=/home/bre/anomy # Set this if you have an external configuration file. Alternatively, # you can configure the sanitizer directly by modifying the ruleset below. SANCFG= # Where do you want temporary files to go? # # Note that the cleanup rules below assume the directory is ONLY used for # sanitizer-related activity and the directory automatically gets created # by the script with rather restrictive permissions. So don't just reset # this to /tmp ! # TMPDIR=/tmp/sanitizer.$LOGNAME ############################################################################## # Set up our working environment... DATE=`date +%Y%m%d-%H%M` MKDIR=`mkdir -p $TMPDIR` SANLOG=$TMPDIR/eml-$DATE-$$.log # This will keep a clean backup copy of all messages in your /tmp directory. # Note that this will chew up disk space if you don't clean it periodically. :0 c $TMPDIR/eml-$DATE-$$.mbx # This will sanitize the message. Note that logging to STDERR is forced # on no matter what the configuration file says, because it's used by the # following recipies. # :0 f |$ANOMY/bin/sanitizer.pl \ "file_name_tpl = $TMPDIR/eml-$DATE-$$"'-$$$-$F' \ $SANCFG \ 'feat_log_stderr = 1' \ 2>$SANLOG # This will add an "X-Found-Virus: Yes" header, if the Sanitizer finds # an infection. Add more recipies like this to add more headers! :-) # :0 f * ? grep 'File was infected' $SANLOG |formail -I"X-Found-Virus: Yes" ## ## Insert other logfile-based actions here, e.g. saving infected messages ## to a seperate mailbox... ## # Delete any files over 5 days old from our temporary directory # #TMPCLEAN=`find $TMPDIR -type f -mtime +5 |xargs rm -f` # Just delete our log file. You don't need this if you decide to use the # find-based cleanup rule above. # #TMPCLEAN=`rm -f $SANLOG`