#!/bin/sh

# clamd-wrapper --	invoke clamdscan for use with mailscanner
#
######  IF YOU ARE RUNNING MAILSCANNER AS ROOT ######
# You need to set the following in MailScanner.conf so that external 
# unpackers can be used...
#   Incoming Work Group = clamav
#   Incoming Work Permissions = 0640

# You may want to check this script for bash-isms

ClamUser="clamav"
ClamGroup="clamav"

ScanOptions=""
ExtraScanOptions=""

# Extra options we try to pass to clam but we handle it failing
# For each option there are two alternatives...
# --option   # if the required program is in the PATH
# --option=/path/to/program  # If its in a non standard location
# If you use the second option make sure you set the correct path in each case

ClamScan=$1/bin/clamdscan
shift

if [ ! -x $ClamScan ]; then
  ClamScan=/usr/bin/clamdscan
fi

if [ "x$1" = "x-IsItInstalled" ]; then
  # Don't include clamd in installed scanners list [ -x $ClamScan ] && exit 0
  exit 1
fi

# Add this for Solaris users so they can find whoami
PATH=$PATH:/usr/ucb
export PATH

$ClamScan $ScanOptions "$@"

retval=$?
if [ "$retval" = "40" ]; then
  # Clam complained we passed an illegal command-line option
  # (As this calls without external unpackers the temp dir isn't used)
  exec $ClamScan $ScanOptions "$@"
else
  exit $retval
fi



syntax highlighted by Code2HTML, v. 0.9.1