#!/bin/sh
#########################
#
# filtro_clamav()
#
# Elimina el mensaje (lo sustituye por otro avisando del cambio)
# si clamav determina que contiene un virus
#
# 

filtro_clamav() {

[ "$CLAMDSCAN" ] || CLAMDSCAN="/usr/bin/clamdscan"

SCAN_INFO=$(crea_temp)

# Contiene archivos infectados?
clamdscan --fdpass "$MSGFILE" &> "$SCAN_INFO"
case $? in
   1) 
      msg_subst "$(msg_date)" "$(msg_from)" "$(msg_to)" "$(msg_subject)" "El mensaje contiene un archivo infectado."> $MSGFILE 
      sed "s#$MSGFILE: ##g" "$SCAN_INFO" >> $MSGFILE
      ;;
   2)
      MSGINFO=$(cat "$SCAN_INFO")
      rm -f "$SCAN_INFO" >/dev/null
      error "error reportado por clamdscan: $MSGINFO"
      ;;
esac

rm -f "$SCAN_INFO" >/dev/null

}
