ClamAV ERROR: getfile: Can’t create new file

While running freshclam in servers, you may encounter this problem.

root@linux [~]# freshclam
ClamAV update process started at Fri Jun 11 19:23:37 2010
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Local version: 0.95.2 Recommended version: 0.96.1
DON’T PANIC! Read http://www.clamav.net/support/faq
ERROR: chdir_tmp: Can’t create directory ./clamav-c1140c4846ffa40c2678e2fdcd1221ee
WARNING: Incremental update failed, trying to download main.cvd
ERROR: getfile: Can’t create new file /usr/local/share/clamav/clamav-9a5f47dee827502d0a4e9cce6648aa3c in /usr/local/share/clamav
Hint: The database directory must be writable for UID 5127 or GID 5127
WARNING: Can’t download main.cvd from database.clamav.net

The issue is that the directory /usr/local/share/clamav/ is missing proper permissions. Run the following command and the freshclam command will work.

root@linux ~]# cd  /usr/local/share/; chown -R clamav.clamav clamav/
root@linux [/usr/local/share]# freshclam
ClamAV update process started at Fri Jun 11 19:23:56 2010
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Local version: 0.95.2 Recommended version: 0.96.1
DON’T PANIC! Read http://www.clamav.net/support/faq
nonblock_connect: connect timing out (30 secs)
Can’t connect to port 80 of host database.clamav.net (IP: 65.120.238.5)
Trying host database.clamav.net (208.72.56.53)…
Downloading main-52.cdiff [100%]
main.cld updated (version: 52, sigs: 704727, f-level: 44, builder: sven)
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Current functionality level = 43, recommended = 44
DON’T PANIC! Read http://www.clamav.net/support/faq
Trying host database.clamav.net (168.143.19.95)…
Downloading daily.cvd [100%]
daily.cvd updated (version: 11181, sigs: 95755, f-level: 51, builder: edwin)
Database updated (800482 signatures) from database.clamav.net (IP: 168.143.19.95)
root@linux [~]#

Hope this helps 🙂

Upgrade ClamAV in cPanel Server

You can upgrade the clamav installations in the server to the latest version by the following steps.

For 32 bit:
cd /usr/local/cpanel/modules-install/clamavconnector-Linux-i686

For 64 bit:
cd /usr/local/cpanel/modules-install/clamavconnector-Linux-x86_64

Then, download the source of the latest version of ClamAV. You can find the download the latest source at http://www.clamav.net/download/sources/

Now, open the file ‘install’. This file is located in the current directory.
vim install

Find the line ‘AVV=0.95′ and change it to ‘AVV=latest version′

Then edit the file ‘progversion’ and put the latest version of ClamAV there. You can do this with a simple command.

echo “latest_version” > progversion

Finally, run the install script with the command ‘./install’.

And thats it. Your ClamAV should now get upgraded to the latest version.