clam wrapper

Mark Sapiro mark at msapiro.net
Fri Jan 29 23:58:43 UTC 2016


On 01/29/2016 01:26 PM, Jerry Benton wrote:
> This is how the is setup:
> 
> TempDir=$(mktemp)
> 
> That makes a tmp file ….



This is a somewhat can of worms, but clamav-wrapper and also
bitdefender-wrapper and kaspersky-wrapper and a couple of other things
used to leave tempfiles behind under some circumstances.

Before the next, we have

if [ "x$1" = "x-IsItInstalled" ]; then
  rm -f ${TempDir}
  [ -x $ClamScan ] && exit 0
  exit 1
fi

which is code to test if clamav is installed and remove the TempDir
before exiting.

> Then …
> 
> # Check if the tmpdir exists, if so delete so we start with a clean slate
> if [ -x "${TempDir}" ]; then
> rm -rf ${TempDir} >/dev/null 2>&1
> fi
> 
> 
> … What the fuck?


Probably left over from when TempDir wasn't a mktemp

> 
> # Make the Temp dir
> umask 0077
> mkdir "${TempDir}" >/dev/null 2>&1
> 
> 
>  … uhhhh … now we are doing it twice


I agree this all seems a bit over the top. But, the module wants to exit
immediately if it can't make TempDir.

I think we could drop the

# Check if the tmpdir exists, if so delete so we start with a clean slate

code since we know we just made it with mktemp and also drop the

# Make the Temp dir

since we already made it.



> then …
> 
> 
> if [ $? ]; then 
>   ExtraScanOptions="$ExtraScanOptions --tempdir=${TempDir}"
>   # If we are root chown it to the clamav user/group
>   if [ `whoami` = "root" ]; then
>     chown ${ClamUser}:${ClamGroup} "${TempDir}"
>   fi
>  fi
> 
> 
> … why? the process that creates the /tmp/blah already owns /tmp/blah


Right, but that's MailScanner and we need to change the group (if we
can) so clamav can read it.


-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan


More information about the MailScanner mailing list