配置clamdscan以扫描Ubuntu 12.04上系统上的所有文件

时间:2014-08-22 00:28:20

标签: ubuntu ubuntu-12.04

我做了以下安装clamscan:

sudo aptitude install clamav 
sudo aptitude install clamav-daemon

并验证:

sudo ps -eal | grep clam
1 S 116 4788 1 2 80 0 - 4004 pause ? 00:00:13 freshclam
1 S 116 5930 1 0 80 0 - 69984 poll_s ? 00:00:00 clamd 

然而,当我尝试通过运行

扫描系统上的所有文件时
#sudo clamdscan /

我不断收到以下错误消息:

  

lstat()失败:权限被拒绝。 ERROR

但是如果我跑

sudo clamscan /

它有效,但这个过程要长得多,不是一个好的选择。

据我所知,clamd使用用户'clamav'并列在/etc/clamav/clamd.conf文件中。我已将用户clamav添加到以下组:root,adm,sudo但它仍然无效。

我也尝试过禁用Apparmor,因为我读到这可能是问题,但没有成功。

1 个答案:

答案 0 :(得分:7)

sudo clamdscan /path/to/some_file.txt会将请求传递给clamd守护程序。该daemun在不同的用户下运行,该用户可能无法访问/path/to/some_file.txt

但是,调用该命令的用户可以很好地访问该文件。要将权限传递给守护程序,请使用--fdpass标志:

--fdpass
    Pass the file descriptor permissions to clamd. This is useful if clamd is running as a different user as it is faster than streaming the file to clamd. Only available if connected to clamd via local(unix) socket. 

在你的情况下,sudo clamdscan --fdpass /应该做到这一点。