Clam Antivirus

(最終更新日時:2008-12-28 21:00:25)
ウィルスメールの検出・隔離・削除を主目的として、アンチウィルスソフト Clam AntiVirus を導入します。
なお、clamav-0.93.1.tar.gz による構築情報は、 http://www.system-act.com/archives/server/clamav.html に移動しました。
参照の状況により予告なく削除いたします。ご了承ください。
なお、今後 Clam AntiVirus の tar による構築情報の更新予定はありません。

インストール

DAGリポジトリから yum でインストールします。
公式サイト : http://www.clamav.net/
# yum -y install clamav clamd

設定

設定ファイルを編集します。
# vi /etc/clamd.conf

       :
# Use system logger (can work together with LogFile).
# Default: no
#LogSyslog yes                                           Syslogへのログ出力を行いません
       :
# Optional path to the global temporary directory.
# Default: system specific (usually /tmp or /var/tmp).
TemporaryDirectory /tmp                                  作業用ディレクトリを /tmp にしています
       :
# Path to a local socket file the daemon will listen on.
# Default: disabled (must be specified by a user)
LocalSocket /var/run/clamav/clamd.socket                 ローカルソケットの位置を変更しています
       :
# TCP port address.
# Default: no
#TCPSocket 3310                                          TCPソケットによる通信は行いません

# TCP address.
       :
#TCPAddr 127.0.0.1                                       TCPソケットによる通信は行いません
       :
#ScanPDF yes
ScanPDF yes                                              PDFファイルをスキャンの対象にします
       :

パターンデータベース

設定ファイルを編集します。
# vi /etc/freshclam.conf

       :
#LogFileMaxSize 2M
LogFileMaxSize 0                                         logrotateでログの容量管理を行います
       :
# Use system logger (can work together with UpdateLogFile).
# Default: no
#LogSyslog yes                                           Syslogへのログ出力を行いません
       :
#PidFile /var/run/freshclam.pid
PidFile /var/run/clamav/freshclam.pid                    Pidファイルを作成します
       :
#AllowSupplementaryGroups yes
AllowSupplementaryGroups yes                             グループ権限も移行させます
       :
パターンデータベースの自動更新を行うため、自動起動ファイルを作成します。
vi /etc/rc.d/init.d/freshclam

#! /bin/bash
#
# freshclam    Start/Stop the freshclam daemon.
#
# chkconfig: - 71 40
# description: freshclam is an update daemon for Clam AV database.
#
# processname: freshclam
# config: /etc/freshclam.conf
# pidfile: /var/run/clamav/freshclam.pid

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

# Get network config
. /etc/sysconfig/network

RETVAL=0

# See how we were called.

prog="freshclam"
progdir="/usr/bin"

start() {
  echo -n $"Starting $prog: "
  daemon $progdir/$prog -d
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/freshclam
  return $RETVAL
}

stop() {
  echo -n $"Stopping $prog: "
  killproc $prog
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && rm -f /var/run/clamav/freshclam.pid /var/lock/subsys/freshclam
  return $RETVAL
}

restart() {
  stop
  start
}

reload() {
  echo -n $"Reloading DB: "
  killproc freshclam -ALRM
  RETVAL=$?
  echo
  return $RETVAL
}


case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status freshclam
    ;;
  restart)
    restart
    ;;
  condrestart)
    [ -f /var/lock/subsys/freshclam ] && restart || :
    ;;
  reload)
    reload
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
    exit 1
esac

exit $?
パターンデータベースの自動更新設定を行います。
# chmod 755 /etc/rc.d/init.d/freshclam
# chkconfig freshclam on

起動

パターンデータベースの更新を先に行い、clamd を起動します。
# service freshclam start

# (初回起動時のみログファイル /var/log/clamav/freshclam.log でパターンデータベースが更新されたことを確認します)

# service clamd     start
a System House to build an Accounting system by the Computer Technology