her er feks et jeg har lavet til glftpd for at scanne filer med sweep antivirus .. det kører som post_check ..
paths er sat til at køre inde i en chroot .. og variablerne er måske lidt anderledes .. men det burde virke
#!/bin/sh
######################################################
# Sophos (
http://www.sophos.com/ ) #
######################################################
SOPHOS_SWEEP='/bin/sweep'
SOPHOS_ARGS='-all -f -archive -tnef -ss'
SAV_IDE='/sav/'
export SAV_IDE
######################################################
# Declaration of some variables #
######################################################
# Where should logs to go?
LOGFILE='/ftp-data/logs/virus.log'
# Prefix of the ftp root directory (relative to chroot)
PREFIX='/site'
######################################################
# #
# Some function(s), which we'll use later #
# #
######################################################
virus_log() {
LOG_DATE=`date +"%a %b %d %T %Y"`
echo "$LOG_DATE '$USER' [$STOR_FILENAME] \"$1\"" >> $LOGFILE
}
# Remove if 0 bytes
if [ ! -s "$2/$1" ]; then
echo "File is 0 bytes, deleting..."
exit 2;
fi
# Get a filename
STOR_FILENAME="$2/$1"
if [ -z $STOR_FILENAME ]; then
virus_log "Filename argument is empty."
exit 0
fi
# Execute sweep
ret=`$SOPHOS_SWEEP $SOPHOS_ARGS "$STOR_FILENAME"`
# Check the return code
case "$?" in
0)
virus_log "Virus scan performed - no viruses found!"
exit 0
;;
1)
virus_log "Unknown error occured (1 returned)"
exit 0
;;
2)
virus_log "File could not be scanned (file itself, or one inside archive, is a part of multivolume archive, most likely)"
exit 0
;;
3)
echo $ret
echo "VIRUS FOUND - removing file"
virus_log "Virus found - deleting file"
exit 2
;;
esac
fi
exit 0