Linuxサーバ奮戦記
--- Clamav-Milter + Sendmail (Fedora12)---   (Mod.10Jan2010)                      >>TOP

Sendmailを組み合わせて,メールのウィルスチェックができるというもので,Fedoara12では Clamav-Milter がFedora9と設定が違っていて Sendmail と連携させるのにかなり苦労をした。なんとか動作が確認できたのでメモとしておく。
ただし,Sendmail は動作していることが前提。

Clamavのインストール
必要になりそうなのをインストール。

# yum install -y clamav
# yum install -y clamav-devel
# yum install -y clamav-milter
# yum install -y clamav-update
# yum install -y clamav-milter-sysvinit
# yum install -y clamav-scanner
# yum install -y clamav-scanner-sysvinit


パターンファイルの更新
freshclam.conf を編集する。

# vi /etc/freshclam.conf
・・・・・
# Comment or remove the line below.
#Example  (コメントアウト)
・・・・・
#DatabaseMirror db.XY.clamav.net
DatabaseMirror db.jp.clamav.net  (追加)
・・・・・
# freshclam


パターンファイルの自動更新
freshclam を編集する。
# vi /etc/sysconfig/freshclam
・・・・・
#FRESHCLAM_DELAY=disabled-warn # REMOVE ME  (コメントアウト)
・・・・・


次は Sendmail と連携させるための設定
scan.conf を編集する。
# vi /etc/clamd.d/scan.conf
・・・・・
# Comment or remove the line below.
#Example  (コメントアウト)
・・・・・
# Path to a local socket file the daemon will listen on.
# Default: disabled (must be specified by a user)
LocalSocket /var/run/clamd.scan/clamd.sock  (#を削除して有効にする)
・・・・・

clamav-milter.conf を編集する。
# vi /etc/mail/clamav-milter.conf
・・・・・
# Comment or remove the line below.
#Example  (コメントアウト)
・・・・・
# Default: no default
MilterSocket /var/run/clamav-milter/clamav-milter.socket  (#を削除して有効にする)
#MilterSocket inet:7357
・・・・・
# Default: no default
#ClamdSocket tcp:scanner.mydomain:7357
ClamdSocket unix:/var/run/clamd.scan/clamd.sock  (追加)
・・・・・
# Default: no
#AddHeader Replace
AddHeader Add  (追加)
・・・・・
注)scan.conf の "LocalSocket /var/run/clamd.scan/clamd.sock" のパスと
clamav-milter.conf の "ClamdSocket unix:/var/run/clamd.scan/clamd.sock" のパスとを一致させることが必要。


clamd.scan と clamav-milter を起動する。
# /etc/rc.d/init.d/clamd.scan start
# /etc/rc.d/init.d/clamav-milter start
# chkconfig clamd.scan on
# chkconfig clamav-milter on


Sendmailの設定
# vi /etc/mail/sendmail.mc
・・・・・
INPUT_MAIL_FILTER(`clamilt', `S=local:/var/run/clamav-milter/clamav-milter.socket, F=, T=S:4m;R:4m')dnl    (追加)
define(`confINPUT_MAIL_FILTERS', `clamilt')dnl    (追加)
MAILER(smtp)dnl
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl
# m4 /usr/share/sendmail-cf/m4/cf.m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf (1行で入力)

Sendmail を再起動する。
# /etc/rc.d/init.d/sendmail restart

メールを送受信して受信メールのヘッダを確認し,以下の様なのが追加されてれば動作しているかな?
・・・・・
X-Virus-Status: Clean
X-Virus-Scanned: clamav-milter 0.95.3 at ayu.yuyuyu.jp
・・・・・