How To Integrate ClamAV Into PureFTPd For Virus Scanning On Fedora 18

This tutorial exists for these OS versions

On this page

  1. 1 Preliminary Note
  2. 2 Installing ClamAV
  3. 3 Configuring PureFTPd
  4. 4 Links

This tutorial explains how you can integrate ClamAV into PureFTPd for virus scanning on a Fedora 18 system. In the end, whenever a file gets uploaded through PureFTPd, ClamAV will check the file and delete it if it is malware.


1 Preliminary Note

You should have a working PureFTPd setup on your Fedora 18 server, e.g. as shown in this tutorial: Virtual Hosting With PureFTPd And MySQL (Incl. Quota And Bandwidth Management) On Fedora 18.


2 Installing ClamAV

ClamAV can be installed as follows:

yum install amavisd-new clamav clamav-data clamav-server clamav-update clamav-scanner

Next we create the system startup links for clamd and start it:

systemctl enable clamd.amavisd.service
systemctl start clamd.amavisd.service


3 Configuring PureFTPd

First we open /etc/pure-ftpd/pure-ftpd.conf and set CallUploadScript to yes :

vi /etc/pure-ftpd/pure-ftpd.conf

# If your pure-ftpd has been compiled with pure-uploadscript support,
# this will make pure-ftpd write info about new uploads to
# /var/run/pure-ftpd.upload.pipe so pure-uploadscript can read it and
# spawn a script to handle the upload.

CallUploadScript yes

Next we create the file /etc/pure-ftpd/ (which will call /usr/bin/clamdscan whenever a file is uploaded through PureFTPd)...

vi /etc/pure-ftpd/

/usr/bin/clamdscan --remove --quiet --no-summary "$1"

... and make it executable:

chmod 755 /etc/pure-ftpd/

Now we start the pure-uploadscript program as a daemon - it will call our /etc/pure-ftpd/ script whenever a file is uploaded through PureFTPd:

pure-uploadscript -B -r /etc/pure-ftpd/

Of course, you don't want to start the daemon manually each time you boot the system - therefore we open /etc/rc.local...

vi /etc/rc.local

... and add the line /usr/sbin/pure-uploadscript -B -r /etc/pure-ftpd/ to it - e.g. as follows:

# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

/usr/sbin/pure-uploadscript -B -r /etc/pure-ftpd/
touch /var/lock/subsys/local

If /etc.rc.local does not exist, create it (with the #!/bin/sh line in the beginning) and then make it executable:

chmod 755 /etc/rc.local

Finally we restart PureFTPd:

systemctl restart pure-ftpd.service

That's it! Now whenever someone tries to upload malware to your server through PureFTPd, the "bad" file(s) will be silently deleted.


Share this page:

0 Comment(s)

Add comment