ClamAVエラー修正

Linux用にAntiVirusを導入していますが、まれにyum update後にcronのエラーメールが送られてくることがあります。

[タイトル]
Anacron job 'cron.daily' on pc-centos
[本文]
/etc/cron.daily/freshclam:

ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
ERROR: Can't open /var/log/clamav/freshclam.log in append mode (check permissions!).

パーミッション絡みのエラーですが、以前メモを残すのを忘れていたので、今後のためにも以下簡易メモ。
※参考 : アンチウィルスソフト導入(Clam AntiVirus)

念のためclamavのログをチェック。

[root@pc-centos ~]# cd /var/log/clamav/
[root@pc-centos clamav]# ls
合計 300
drwxr-xr-x 2 clamav clamav 4096 10月 20 03:50 2013 ./
drwxr-xr-x. 13 root root 4096 10月 20 03:50 2013 ../
-rw-r----- 1 clamav clamav 3717 10月 20 14:20 2013 clamd.log
-rw-r----- 1 clam clam 62841 9月 29 03:49 2013 clamd.log-20130929
-rw-r----- 1 clam clam 61981 10月 6 03:42 2013 clamd.log-20131006
-rw-r----- 1 clam clam 59536 10月 13 03:46 2013 clamd.log-20131013
-rw-r----- 1 clam clam 59708 10月 20 03:50 2013 clamd.log-20131020
-rw-r----- 1 clamav clamav 0 10月 15 03:12 2013 freshclam.log
-rw-r----- 1 clam clam 3974 9月 15 03:25 2013 freshclam.log-20130915
-rw-r----- 1 clam clam 4675 9月 22 03:33 2013 freshclam.log-20130922
-rw-r----- 1 clam clam 4418 9月 29 03:49 2013 freshclam.log-20130929
-rw-r----- 1 clam clam 2335 10月 15 03:12 2013 freshclam.log-20131015
/*
[root@pc-centos clamav]# chown clamav:clamav clamd.log*
[root@pc-centos clamav]# chown clamav:clamav freshclam.log*
[root@pc-centos clamav]# ls
合計 300
drwxr-xr-x 2 clamav clamav 4096 10月 20 03:50 2013 ./
drwxr-xr-x. 13 root root 4096 10月 20 03:50 2013 ../
-rw-r----- 1 clamav clamav 3717 10月 20 14:20 2013 clamd.log
-rw-r----- 1 clamav clamav 62841 9月 29 03:49 2013 clamd.log-20130929
-rw-r----- 1 clamav clamav 61981 10月 6 03:42 2013 clamd.log-20131006
-rw-r----- 1 clamav clamav 59536 10月 13 03:46 2013 clamd.log-20131013
-rw-r----- 1 clamav clamav 59708 10月 20 03:50 2013 clamd.log-20131020
-rw-r----- 1 clamav clamav 0 10月 15 03:12 2013 freshclam.log
-rw-r----- 1 clamav clamav 3974 9月 15 03:25 2013 freshclam.log-20130915
-rw-r----- 1 clamav clamav 4675 9月 22 03:33 2013 freshclam.log-20130922
-rw-r----- 1 clamav clamav 4418 9月 29 03:49 2013 freshclam.log-20130929
-rw-r----- 1 clamav clamav 2335 10月 15 03:12 2013 freshclam.log-20131015
*/

本来であれば、clamavユーザーでログを残しますが、ClamAV自体を最新版にした際に、confファイルが新しいものに置き換わるようです。というか、インストール先も変更されてますね…。

[root@pc-centos ~]# vi /etc/clamd.conf

# Run as another user (clamd must be started by root for this option to work)
# Default: don't drop privileges
#User clam
 ↓
User clamav

“/etc/clamd.conf”内の“#User clam”のコメント部分を有効にし、ユーザーを“clamav”に変更します。

[root@pc-centos ~]# vi /etc/freshclam.conf

# By default when started freshclam drops privileges and switches to the
# "clamav" user. This directive allows you to change the database owner.
# Default: clamav (may depend on installation options)
DatabaseOwner clam
 ↓
DatabaseOwner clamav

/etc/freshclam.conf 内の “DatabaseOwner clam”のユーザーを“clamav”に変更します。

[root@pc-centos ~]# cd /var/lib/clamav
[root@pc-centos clamav]# ls
合計 185816
drwxr-xr-x 2 clam clam 4096 10月 15 03:12 2013 ./
drwxr-xr-x. 31 root root 4096 7月 30 17:04 2013 ../
-rw-r--r-- 1 clam clam 345088 10月 15 03:12 2013 bytecode.cld
-rw-r--r-- 1 clam clam 26437632 10月 15 03:12 2013 daily.cld
-rw-r--r-- 1 clam clam 163468288 9月 19 03:39 2013 main.cld
-rw------- 1 clam clam 364 10月 15 03:12 2013 mirrors.dat

[root@pc-centos clamav]# chown clamav:clamav /var/lib/clamav/
[root@pc-centos clamav]# chown clamav:clamav *
[root@pc-centos clamav]# ls
合計 185816
drwxr-xr-x 2 clam clam 4096 10月 15 03:12 2013 ./
drwxr-xr-x. 31 root root 4096 7月 30 17:04 2013 ../
-rw-r--r-- 1 clamav clamav 345088 10月 15 03:12 2013 bytecode.cld
-rw-r--r-- 1 clamav clamav 26437632 10月 15 03:12 2013 daily.cld
-rw-r--r-- 1 clamav clamav 163468288 9月 19 03:39 2013 main.cld
-rw------- 1 clamav clamav 364 10月 15 03:12 2013 mirrors.dat

インストール先が新しくなりましたので、“/var/lib/clamav”以下のデータ類のユーザーとグループを“clamav”に変更します。

これで正常に更新できるようになりました。以降エラーメールも来なくなりますが、一応手動でちゃんと更新できるか確認してみるのがいいでしょう。

Follow me!

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください