ClamAV can't write to /tmp

Although I can run clamav from the command line, any attempt to configure settings in Virtualmin>Email Messages>Spam and Virus Scanning yields the following:

The selected virus scanning command does not work :
ERROR: Can’t write to temporary directory

----------- SCAN SUMMARY -----------
Known viruses: 833586
Engine version: 0.96.1
Scanned directories: 0
Scanned files: 0
Infected files: 0
Data scanned: 0.00 MB
Data read: 0.00 MB (ratio 0.00:1)
Time: 4.999 sec (0 m 4 s)

What could be causing this error?

The permissions on /tmp are set correctly (i.e., are consistent with chmod 1777 /tmp). Running Ubuntu 10.04

Are you by chance using the ClamAV server scanner mode (clamdscan), rather than the command line scanner?

You can determine that by looking in Email Messages -> Spam and Virus Scanning, and looking at “Virus scanning program”.

If you aren’t set to use the server scanner (clamdscan), I’m curious if things begin working if you switch to that (which is a setting I recommend anyhow).

-Eric

anreycheck,

No, I am not using the daemon, but rather the command line version. I have been reticent to change the settings to use the daemon, for fear that the error reported above would prevent me from changing them back. I am on a memory tight VPS, and although I have sufficient resources to run the daemon for at least short periods of time, I do not have sufficient memory available to run clamdscan indefinitely.

In your clamd.conf file (which would be something like /etc/clamav/clamd.conf ), what is the “TemporaryDirectory” parameter set to?

-Eric

andreychek, good question! It is currently set to:

TemporaryDirectory is not set to its default /tmp here to make overriding

the default with environment variables TMPDIR/TMP/TEMP possible

(i.e., nothing)

I had tried, briefly, the following:

TemporaryDirectory /tmp

With no change in behavior.

I hate to do this, but…bump! This is very important to me that I be able to fix this, and I haven’t been able to find anything helpful anywhere else. Anyone?

I have experienced a similar problem, under ubuntu 10.04 LTS and Debian Lenny, both running in a Virtuozzo container.

You should do a printenv or printenv TMPDIR, to verify that your TMPDIR environment variable does in fact contain the /tmp path. I didn’t see in the posted output any absolute path listed to the temporary directory clam is trying to write to.

If it’s something other than /tmp then that is the directory whose permissions need to be changed, as clam is going to use whatever path is stored in $TMPDIR. Alternatively, you could specify your own custom tmp directory for the clamav config parameter “TemporaryDirectory.”

You could edit /etc/environment and define TMPDIR=/fs/some/dir however you like, and applications like clamav should respect that. I’m really not sure about this, but if you’re working in a virtuozzo container, the mount flags and fs types on relevant partitions might cause apps like clamav (under certain circumstances) to be unable to work within the default tmp directory. For instance I had to reconfigure apt-get package management tool to utilize an alternate tmp directory elsewhere on the filesystem, because my default $TMPDIR is mounted noexec. This prevents packages that build test and preconfigure by executing temporary code from successfully installing.

I am an amateur, but I should offer a word of warning: the matter of /tmp directory security is quite important. Depending on your distro there might be a couple of default tmp directories on your file-system subject to mount point fs type and any number of options for limiting how the mounted directory may be used.

Poor security on primary temporary directories can leave an easy back door for the execution of arbitrary code, scripts malicious or otherwise which might be allowed to rapidly consume memory and disk capacity. The flip side of course is perhaps minor problems configuring or compiling new software with parameters that allow compatibility with your security measures.