如何将ClamAV集成到PureFTPd中,以便在OpenSUSE 11.2上进行病毒扫描
本教程将介绍如何将ClamAV集成到PureFTPd中,以便在OpenSUSE 11.2系统上进行病毒扫描。 最后,每当通过PureFTPd上传文件时,ClamAV将检查文件并将其删除,如果它是恶意软件。
我不会保证这将为您工作!
1初步说明
您应该在OpenSUSE 11.2服务器上安装一个工作的PureFTPd设置,例如本教程所示: 使用PureFTPd和MySQL进行虚拟托管(包括配额和带宽管理)在OpenSUSE 11.2上 。
2安装ClamAV
ClamAV可以安装如下:
yast2 -i clamav clamav-db
接下来,我们为clamd创建系统启动链接并启动它:
chkconfig --add clamd
/etc/init.d/clamd start
3配置PureFTPd
首先,我们打开/etc/pure-ftpd/pure-ftpd.conf
并将Umask
设置为133:022
(以便clamdscan具有读取上传文件的正确权限)和CallUploadScript
为yes
:
vi /etc/pure-ftpd/pure-ftpd.conf
[...] # File creation mask. <umask for files>:<umask for dirs> . # 177:077 if you feel paranoid. Umask 133:022 [...] # 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 [...] |
接下来,我们创建文件/etc/pure-ftpd/clamav_check.sh
(每当通过PureFTPd上传文件时,它将调用/ usr / bin /
clamdscan)...
vi /etc/pure-ftpd/clamav_check.sh
#!/bin/sh /usr/bin/clamdscan --remove --quiet --no-summary "$1" |
...并使其可执行:
chmod 755 /etc/pure-ftpd/clamav_check.sh
现在我们启动pure-uploadscript
程序作为守护进程,每当通过PureFTPd上传文件时,它将会调用我们的/etc/pure-ftpd/clamav_check.sh
脚本:
pure-uploadscript -B -r /etc/pure-ftpd/clamav_check.sh
当然,你不想在启动系统时手动启动守护进程 - 因此我们打开/etc/init.d/boot.local
...
vi /etc/init.d/boot.local
...并将/ usr / sbin / pure-uploadscript -b -r /etc/pure-ftpd/clamav_check.sh添加
到其中 - 如下所示:
#! /bin/sh # # Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany. All rights reserved. # # Author: Werner Fink <werner@suse.de>, 1996 # Burchard Steinbild, 1996 # # /etc/init.d/boot.local # # script with local commands to be executed from init on system startup # # Here you should add things, that should happen directly after booting # before we're going to the first run level. # /usr/sbin/pure-uploadscript -B -r /etc/pure-ftpd/clamav_check.sh |
最后我们重新启动PureFTPd:
/etc/init.d/pure-ftpd restart
而已! 现在每当有人尝试通过PureFTPd将恶意软件上传到您的服务器时,“坏”文件将被默认删除。
4链接
- PureFTPD: http : //www.pureftpd.org/
- ClamAV: http : //www.clamav.net/
- OpenSUSE: http : //www.opensuse.org/