piyo
■ClamAV 0.90 へのバージョンアップ

■CentOS 4.4 + ClamAV 0.90

しばらくWeb更新もせずに(飽きた、という説が有力)さぼっていたものの、サーバのメンテナンスはさぼらずにきちんと続けているわけで、OSもいつの間 にかCentOS 4.4 に上がっていたりして。ウィルスチェックソフトのClamAVも0.8xから0.9xにリビジョンアップしました。いつの間にか公式サイトには日本語ページも出来ているし、 メジャーになってきたので有償化されないかどうか心配になりますが、"Clam AntiVirus is a GPL anti-virus toolkit for UNIX" と言ってるので当面は平気なんでしょう。

さて、0.90になって機能も上がっているようで、0.88.7に上書きインストールでは起動しませんでしたので、コンフィグを作り直しました。インス トールメモを公開します。初めてインストールする人は、こっちも参照してください。最初は sendmailの設定変更とか、いろいろとやることがあります。
■ソースの取得、インストール
ソースを取ってきてインストールします。
# cd /usr/local/src
# wget http://freshmeat.net/redir/clamav/29355/url_tgz/clamav-0.90.tar.gz
# tar zxvf clamav-0.90.tar.gz
# cd clamav-0.90
# ./configure --enable-milter --disable-zlib-vcheck
# make
# make install

CentOS 4.4 環境では、--disable-zlib-vcheck オプションを入れてやらないとconfigureスクリプトが通りません。

■設定ファイルの修正
サンプルをコピーします。
# cp /usr/local/src/clamav-0.90/etc/clamd.conf /usr/local/etc/
# cp /usr/local/src/clamav-0.90/etc/freshclam.conf /usr/local/etc/

修正します。
# vi /usr/local/etc/clamav.conf
[/usr/local/etc/clamav.conf]
8c8
< Example
---
> #Example
14c14
< #LogFile /tmp/clamd.log
---
> LogFile /var/log/clamd.log
30c30
< #LogFileMaxSize 2M
---
> LogFileMaxSize 0
34c34
< #LogTime yes
---
> LogTime yes
39c39
< #LogClean yes
---
> LogClean yes
57c57
< #PidFile /var/run/clamd.pid
---
> PidFile /var/run/clamav/clamd.pid
61c61
< #TemporaryDirectory /var/tmp
---
> TemporaryDirectory /tmp
72c72
< LocalSocket /tmp/clamd
---
> LocalSocket /var/run/clamav/clamd
145c145
< #User clamav
---
> User clamav

# vi /usr/local/etc/freshclam.conf
[/usr/local/etc/freshclam.conf]
8c8
< Example
---
> #Example
17c17
< #UpdateLogFile /var/log/freshclam.log
---
> UpdateLogFile /var/log/clamd-update.log
55c55
< #DatabaseMirror db.XY.clamav.net
---
> DatabaseMirror db.jp.clamav.net
95c95
< #NotifyClamd /path/to/clamd.conf
---
> NotifyClamd /usr/local/etc/clamd.conf

■起動スクリプトの修正
0.90では、clamdを起動してから LocalSocketが生成されるまでに数秒かかるようになりました。
clamav-milterが起動時にLocalSocketを参照するため、従来の起動スクリプトでは起動に失敗します。
LocakSocketが生成されたのを確認してからclamav-milterを起動するように、ウェイトを入れてみました。
太字箇所が修正部分。

[/etc/init.d/clamav]
#!/bin/bash
#
# clamav      This shell script takes care of starting and stopping
#             clamAV.
#
# chkconfig: 2345 78 30
# description: clamAV is an anti-virus daemon.

# Source function library.
. /etc/rc.d/init.d/functions

start() {
        echo -n "Starting clamd:"
        /usr/local/sbin/clamd
        RETVAL=$?
        [ $RETVAL -eq 0 ] && echo_success
        [ $RETVAL -ne 0 ] && echo_failue
        echo

        echo -n "Starting clamav-milter:"
       echo
       a=0
       while test $a -lt 1
       do
               echo "searching socket file .........."
               sleep 2
               if [ -e /var/run/clamav/clamd ]; then
                       a=`expr $a + 1`
               fi
       done

        /usr/local/sbin/clamav-milter -eNPlo /var/run/clamav/clmilter.sock
        RETVAL=$?
        [ $RETVAL -eq 0 ] && echo_success
        [ $RETVAL -ne 0 ] && echo_failue
        echo

        echo -n "Starting freshclam:"
        /usr/local/bin/freshclam -d
        RETVAL=$?
        [ $RETVAL -eq 0 ] && echo_success
        [ $RETVAL -ne 0 ] && echo_failue
        echo
}

stop() {
        for i in clamav-milter clamd freshclam
        do
                echo -n "Stopping $i:"
                killproc $i
                echo
        done
        if [ -e /var/run/clamav/clmilter.sock ]; then
                rm /var/run/clamav/clmilter.sock
        fi
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
        ;;
esac

再起動すると、こんな感じ。
# service clamav restart
Stopping clamav-milter:                                    [  OK  ]
Stopping clamd:                                            [  OK  ]
Stopping freshclam:                                        [  OK  ]
Starting clamd:Running as user clamav (UID 512, GID 512)
                                                           [  OK  ]
Starting clamav-milter:
searching socket file ..........
searching socket file ..........
searching socket file ..........
searching socket file ..........
                                                           [  OK  ]
Starting freshclam:                                        [  OK  ]

■バージョン監視
バージョンアップ監視のスクリプトは、その後若干の修正を経て、現在はこうなってます。
[/etc/cron.daily/clamav-vchk.sh]
#!/bin/sh

LOG=/var/log/clam-update.log
DAY=`date +"%a %b %d" --date="1 days ago"`

echo "ClamAV Version check:"
grep -A 2 "$DAY" $LOG | grep Recommended | uniq
echo "ClamAV current version:"
/usr/local/sbin/clamd --version

バージョンが上がると、こんな通知が来ます。
ClamAV Version check:
WARNING: Local version: 0.88.7 Recommended version: 0.90
ClamAV current version:
ClamAV 0.88.7/2568/Thu Feb 15 00:42:10 2007
/etc/cron.daily/raidchk.sh:

■clamav-milter のオプション
 指定できるオプションが増えてます。赤は私が指定しているもの、青は新たに増えたもの。
 字消しは廃止されたもの。
オプション
短縮形
概    要
--advisory
-A
Flag viruses rather than deleting them.
--blacklist=time
-k
Time (in seconds) to blacklist an IP.
--black-hole-mode

Don't scan messages aliased to /dev/null.
--bounce
-b
Send a failure message to the sender.
--broadcast
-B [IFACE] Broadcast to a network manager when a virus is found.
--config-file=FILE
-c FILE
Read configuration from FILE.
--debug
-D
Print debug messages.
--detect-forged-local-address
-L
Reject mails that claim to be from us.
--dont-blacklist
-K
Don't blacklist a given IP.
--dont-log-clean
-C Don't add an entry to syslog that a mail is clean.
--dont-scan-on-error
-d
Pass e-mails through unscanned if a system error occurs.
--dont-wait

Ask remote end to resend if max-children exceeded.
--external
-e
Use an external scanner (usually clamd).
--freshclam-monitor=SECS
-M SECS
How often to check for database update.
--from=EMAIL
-a EMAIL
Error messages come from here.
--force-scan
-f
Force scan all messages (overrides (-o and -l).
--help
-h
This message.
--headers
-H
Include original message headers in the report.
--ignore IPaddr
-I IPaddr
Add IPaddr to LAN IP list (see --local).
--local
-l
Scan messages sent from machines on our LAN.
--max-childen
-m
Maximum number of concurrent scans.
--outgoing
-o
Scan outgoing messages from this machine.
--noreject
-N
Don't reject viruses, silently throw them away.
--noxheader
-n
Suppress X-Virus-Scanned/X-Virus-Status headers.
--pidfile=FILE
-i FILE
Location of pidfile.
--postmaster
-p EMAIL
Postmaster address [default=postmaster].
--postmaster-only
-P
Send warnings only to the postmaster.
--quiet
-q
Don't send e-mail notifications of interceptions.
--quarantine=USER
-Q EMAIL
Quanrantine e-mail account.
--quarantine-dir=DIR
-U DIR
Directory to store infected emails.
--server=SERVER
-s SERVER
Hostname/IP address of server(s) running clamd (when using TCPsocket).
--sendmail-cf=FILE

Location of the sendmail.cf file to verify
--sign
-S
Add a hard-coded signature to each scanned message.
--signature-file=FILE
-F FILE
Location of signature file.
--template-file=FILE
-t FILE
Location of e-mail template file.
--template-headers=FILE

Location of e-mail headers for template file.
--timeout=SECS
-T SECS
Timeout waiting to childen to die.
--whitelist-file=FILE
-W FILE
Location of the file of whitelisted addresses
--version
-V
Print the version number of this software.

とりあえず、こんなところで。(2007.02.17)