最近ではSMTPが稼働するサーバ上に多様なウイルスが通過する。ほとんどの物はWindowsプラットフォームを目的としているため、Linuxサーバ自体には実害がない。しかし、POPサーバにアクセスするクライアントはWindowsが多いことから、なるべくであればサーバ上で駆除を行いたい。このような目的に応えるSMTP対応のアンチウイルスソフトは、商用であれば各社からリリースされている。
ここで紹介するのは、個人利用に限り無料とされているH+BEDVの「AntiVir Mailgate for Linux」だ。定期的にワクチンも配布されており、cronでスケジュールを行えば、ほぼメンテナンスフリーの環境ができあがる。
まず最初に、H+BEDVサイトの「AntiVir for E-Mail」から「AntiVir Mailgate for Linux」項目を探し出し、ダウンロードおよびインストールをしよう。さらに、レジストリファイルが後で必要になるため、このページで登録をしておくのがよい。場合によっては、メールの到着まで数十分から数時間かかるかもしれない。
$ wget http://www.hbedv.com/files/antivir/release/avlxmgt.tgz $ tar zxfv avlxmgt.tgz $ cd antivir-mailgate-2.0.1.10 $ ls -l 合計 48 -rw-r--r-- 1 ykida ykida 5535 12月 3 18:56 LIESMICH -rw-r--r-- 1 ykida ykida 4235 12月 3 18:56 README -rw-r--r-- 1 ykida ykida 9 12月 3 18:56 VERSION -rwxr-xr-x 1 ykida ykida 23385 12月 3 18:56 avinstall.pl drwxr-xr-x 12 ykida ykida 4096 2月 14 22:27 avmailgate $ su # ./avinstall.pl Do you agree the LICENSE (y/n):y Enter the path of init directory (default is: /etc/rc.d): /etc/rc.d Enter the path where AntiVir MailGate binaries will be located (default is: /usr/sbin): /usr/sbin Enter the path where scan engine and virus definition file will be located (default is: /usr/lib/AntiVir): /usr/lib/AntiVir Enter the path where manual pages will be located (default is: ): The directory doesn't exists. Try again! Should I create it? (y/n): y The automatic internet updater will check every hour if a new update is available. Default is yes. Install the automatic internet updater? (y/n): y |
続けてメインの設定ファイル編集を行う。
# vi /etc/avmailgate.conf User uucp Group uucp Postmaster postmaster MyHostName example.jp SpoolDir /var/spool/avmailgate AntiVirDir /usr/lib/AntiVir TemporaryDir /tmp SMTPBanner "AntiVir MailGate" # PidDir /var/tmp PidDir /var/run/antivir # ListenAddress 0.0.0.0 port 25 ListenAddress localhost port antivir ForwardTo SMTP: localhost port smtp-backdoor VirusAlertsUser root |
上記のリストは、設定が有効になっている行だけをピックアップし、編集を行うべき個所をまとめたものだ。「#」行はあえて変更したことを明示している。中でも「PidDir」項目は注意が必要であり、デーモン稼働フラグ(PID)を記録するディレクトリを「uucp」ユーザー(グループ)に設定する必要がある。このため、次のように/var/run/ディレクトリ下に専用のディレクトリを作成しよう。
# mkdir -m 755 /var/run/antivir # chown uucp:uucp /var/run/antivir |
ここまででデーモンとして稼働が可能だ。しかし、すぐに停止させてSMTPサーバとの連携設定を行おう。
# /etc/rc.d/init.d/avgate start Shutting down AntiVir MailGate service: [ OK ] # /etc/rc.d/init.d/avgate stop Shutting down AntiVir MailGate service: [ OK ] |
このTipsでは、特にPostfixとの連携方法を挙げる。なお、Postfix自体の稼働までは「メールサーバを動かしたい〜Postfix編〜」Tipsを参考にしてほしい。
連携設定は次のようになる。挙げるそれぞれの1行を最下段にでも追加すればよい。追加させる個所は問わない。
# vi /etc/postfix/master.cf localhost:10025 inet n - n - - smtpd -o content_filter= # vi /etc/postfix/main.cf content_filter = smtp:127.0.0.1:10024 |
冒頭で挙げたレジストファイルがメールで到着したら、サーバ外で受け取った際にはftpやSamba経由で転送し、AntiVir MailGateのバイナリディレクトリ(/usr/lib/AntiVir/)に移動する。また、このファイルをuucpユーザー(グループ)に変更しよう。
# mv ~/hbedv.key /usr/lib/AntiVir/hbedv.key # chown uucp:uucp /usr/lib/AntiVir/hbedv.key |
ここまでで設定が完了だ。AntiVir MailGateのデーモン起動をしよう。続けてPostfixの設定も有効にすれば、すべてが稼働状態になる。
# /etc/rc.d/init.d/avgate start Shutting down AntiVir MailGate service: [ OK ] # postfix stop # postfix start |
なお、ワクチンパターンファイルの更新はcronに設定しておけばよいだろう。定期的に最新のワクチンに更新される。ここでの例は、0/3/6/9/12/15/18/23時それぞれの2分にパターン更新を実行する指定だ。cron指定については「定期的にプログラムを実行できるcronの使い方を知りたい」Tipsを参考にしてほしい。
# crontab -e 2 0,3,6,9,12,15,18,23 * * * /usr/sbin/antivirupdater -q |
実際に処理されているかどうかは、SMTPサーバを通過したメールのヘッダを見てみればよい。次のように記録されていればOKだ。
X-AntiVirus: checked by AntiVir MailGate (version: 2.0.1.10; AVE: 6.18.0.2; VDF: 6.18.0.7; host: xxxxxxx.jp) |
ウイルスがキャッチされると次に挙げるようなメールが/etc/avmailgate.confファイル内で設定したPostmaster項目のアカウント宛に届く。
AntiVir ALERT [mail from: kokiki@d7.xxxx.ne.jp] * * * * * * * * * * * * * * * AntiVir ALERT * * * * * * * * * * * * * * * This version of AntiVir is licensed for private and non-commercial use. AntiVir has detected the following in a mail sent through your server: Worm/Klez.E virus The mail was not delivered. It has been quarantined with the following queue id: 25647-579F1CED Mail-Info: 〜中略〜 -- AntiVir for UNIX Copyright (C) 1994-2002 by H+BEDV Datentechnik GmbH. All rights reserved. For more information see http://www.antivir.de/ or http://www.hbedv.com/ |
Copyright © ITmedia, Inc. All Rights Reserved.