1
1

More than 1 year has passed since last update.

ClamAV まとめ

Last updated at Posted at 2022-06-09

インストールおよび設定

# yum --enablerepo=epel install clamav clamav-update clamd
# freshclam
# vim /etc/freshclam.conf

以下を有効にする。

UpdateLogFile /varf/log/freshclam.log
LogTime yes
PidFile /var/run/freshclam.pid

もし、logwatch を使っている場合は、以下を実行する。

# vim /etc/logwatch/conf/logfiles/clam-update.conf

LogFile = /var/log/freshclam.log

ClamAV の更新確認

# freshclam

定期的に更新しログに取る。

# vim /etc/cron.d/clamav-update
====
## Adjust this line...
MAILTO=root

# 0  */3 * * * root /usr/share/clamv/freshclam-sleep > /dev/null
30 */3 * * * root /usr/bin/freshclam >> /var/log/freshclam.log
====
# vim /etc/sysconfig/freshclam
FRESHCLAM_DELAY=disabled-warn

それとも、以下の方法にして、cron の方を消してみるのはどうだろうか。ダブルでやっておけば安心なので、残しておいてもいいですけど。

新規ファイルの作成。 /usr/lib/systemd/system/clam-freshclam.service
以下の設定で、1日に4回アップデートを試みます。

# Run the freshclam as daemon
[Unit]
Description = freshclam scanner
After = network.target

[Service]
Type = forking
ExecStart = /usr/bin/freshclam -d -c 4
Restart = on-failure
PrivateTmp = true

[Install]
WantedBy=multi-user.target

freshclam サービスの有効化と実行

systemctl enable clam-freshclam.service
systemctl start clam-freshclam.service

以下を編集

# vim /etc/clamd.d/scan.conf

====
LogFile /var/log/clamd.scan
LogTime yes
PidFile /var/run/clamd.scan/clamd.pid
LocalSocket /var/run/clamd.scan/clamd.sock
# User clamscan

ExcludePath ^/proc/
ExcludePath ^/sys/
ExcludePath ^/dev/
ExcludePath ^/swap.file
====

起動設定

# systemctl start clamd@scan
# systemctl status clamd@scan
# systemctl enable clamd@scan
# ln -sfv /etc/clamd.d/scan.conf /etc/clamd.conf

Web からアクセスできるようにする。

# usermod -aG clamscan apache
# usermod -aG virusgroup apache
# id apache

PrivateTmp の設定
これやらないとうまくいかないところなのだが、うーーん、と言う感じ。

# vim /etc/systemd/sysetm/php-fpm.service.d/php-fpm.service
====
[Service]
PrivateTmp=false
====

SELinux 設定

# getsebool -a | grep antivirus
antivirus_can_scan_system --> off
antivirus_use_jit --> off

#setsebool -P antivirus_can_scan_system 1

# getsebool -a | grep antivirus
antivirus_can_scan_system --> on
antivirus_use_jit --> off

# setsebool -P httpd_can_sendmail 1

サービス再起動

# systemctl restart php-fpm
# systemctl restart httpd
# systemctl restart clamd@scan

いずれにしろ、以下は確認する必要がある。

# systemctl status clamd@scan
# systemctl status clam-freshclam

ところで、logwatch が clam-update とか freshclam のアップデート状況を補足できないようで、うるさく言ってくるので、以下の処置をおこなった。

# vim /etc/logwatch/conf/ignore.conf

feshclam
clam-update
If you use a different log file
 you may need to restart it
For example
 If you are logging using syslog
Other options

なお、メモリは、1G 程度は必要となるため、インスタンスのメモリは 4G 以上のものが必要となるでしょう。

(参考)
freshclam
https://linux-audit.com/install-clamav-on-centos-7-using-freshclam/
擬似ウィルス
https://downloadcenter.trendmicro.com/index.php?regs=jp&prodid=1424

なお、運用を始めてしばらくして、clamd が古いと言われて freshclam ができない問題が、AWS の EC2 で発生しました。この問題への対応は、以下のリンクを参考にしてください。

Packages excluded due to repository priority protections の解決方法

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1