manekineko倉金家ホームページ

趣味の部屋/サーバー構築メモ その2/メールサーバー その2

メールのウィルスチェック

2010年10月20日(水)
ウィルスはメールで伝搬することが多く、ウィルスチェックは世間に迷惑をかけないためにも必須です。postfixにウィルスチェックを導入します。

先にウィルススキャンエンジンとしてclamdとclamsmtpを導入しておきました。
postfix側にそれを使う設定をします。

/etc/postfix/main.cf の最後のほうにでも、
# Clamsmtp Virus Scannerの設定
content_filter = virus-scan:127.0.0.1:10025
を追加。

/etc/postfix/master.cf の最後に以下を追加。
#
# Virus Scanner Settings
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ==========================================================================

# postfixからclamsmtpへ
virus-scan unix - - n - 16 smtp
-o smtp_send_xforward_command=yes
-o smtp_data_done_timeout=1200
-o disable_dns_lookups=yes

#clamsmtpよりpostfixへ
127.0.0.1:10026 inet n - n - 16 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o mynetworks=127.0.0.0/8
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000

その昔Vineで設定したのをそのまま。
当時よくわからず、もしかして不要なことも書いてるかも。でもちゃんと動いているのでこのままでいいか。
サーバーを再起動してメール送信テストをしてみます。
以前ダウンロードしたテストウィルスを添付。
...
久々にSELinuxさん登場。
clamdが/var/tmp/clamav/clamsmtpに書き込むのはいけないんだそうです。
隔離ディレクトリの場所の指定を設定で変えちまったからかな。(ディフォルトは /tmp となっていましたが、ウィルスファイルをここに撒き散らされるのはどうも...。)

SELinux Administration より、Boolian -> SELinux Service Protection の
Disable SELinux protection for clamd daemon
にチェック。再起動。

再度ウィルス有りと無しのメールを送信。
ウィルス無しはちゃんと配送されます。
ウィルス有は配送されず、代わりにrootに警告メールが送信されます。
OK!