2020年04月07日

RHEL7/CentOS7 で最新版 clamav のオンアクセススキャン機能を利用する手順について

先月 clamav パッケージが 0.102 にバージョンアップした際に、 RHEL 7 / CentOS 7 で提供されている curl のバージョンが古すぎることが原因で、 RHEL 7 / CentOS 7 向けの clamav におけるオンアクセススキャン機能が「突然」使えなくなってしまいました。

オンアクセススキャン機能を必要としている人は、業務で使っている人が多いと思うので、今すぐ RHEL 8 / CentOS 8 に乗り換えるという選択肢は難しいと思います。なので、既存環境への影響を最小限に抑えながら、 RHEL 7 / CentOS 7 環境でもオンアクセススキャン機能を使えるようにするための手順を作りました。

(1) ビルドに必要なパッケージを開発環境にインストールします。

# yum -y install gcc rpm-build yum-utils wget epel-release

(2) curl の最新版(記事作成時点では 7.69.1 )を開発環境でコンパイルします。

# wget https://curl.haxx.se/download/curl-7.69.1.tar.bz2 \
       https://curl.haxx.se/download/curl-7.69.1.tar.bz2.asc \
       https://daniel.haxx.se/mykey.asc
# gpg --import mykey.asc
# gpg curl-7.69.1.tar.bz2.asc
# tar -xf curl-7.69.1.tar.bz2
# cd curl-7.69.1
# ./configure --prefix=/usr/local/curl-7.69.1
# make
# make install

(3) clamav の最新版(記事作成時点では 0.102.2-4.el7 )を開発環境でコンパイルします。

# cd
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
# yumdownloader --source clamav
# rpm --checksig clamav-0.102.2-4.el7.src.rpm
# rpm -ivh clamav-0.102.2-4.el7.src.rpm
# yum-builddep -y ~/rpmbuild/SPECS/clamav.spec
# patch -d ~/rpmbuild/SPECS/ -p0 << "EOF"
--- clamav.spec
+++ clamav.spec
@@ -4,7 +4,7 @@

 ## Fedora Extras specific customization below...
 # EL7's curl is too old
-%if 0%{?fedora} || 0%{?rhel} >= 8
+%if 0%{?fedora} || 0%{?rhel} >= 7
 %bcond_without  clamonacc
 %else
 %bcond_with     clamonacc
@@ -264,6 +264,7 @@ export have_cv_ipv6=yes
 rm -rf libltdl autom4te.cache Makefile.in
 autoreconf -i
 %configure \
+    --with-libcurl=/usr/local/curl-7.69.1 \
     --enable-milter \
     --disable-clamav \
     --disable-static \
EOF
# rpmbuild -bb ~/rpmbuild/SPECS/clamav.spec

(4) 開発環境で作成したファイルを本番環境にコピーします。なお、開発環境と本番環境が同一の場合は不要です。

# tar -cf ~/curl+clamav.tar /usr/local/curl-7.69.1/ ~/rpmbuild/RPMS/x86_64/clamd-*.rpm \
          ~/rpmbuild/RPMS/x86_64/clamav-*.rpm ~/rpmbuild/RPMS/noarch/clamav-*.rpm
# tar -xf ~/curl+clamav.tar -C /

(5) 本番環境で clamav パッケージをインストールします。

# rpm -ivh ~/rpmbuild/RPMS/x86_64/clamd-0.102.2-4.el7.x86_64.rpm \
           ~/rpmbuild/RPMS/x86_64/clamav-0.102.2-4.el7.x86_64.rpm \
           ~/rpmbuild/RPMS/x86_64/clamav-lib-0.102.2-4.el7.x86_64.rpm \
           ~/rpmbuild/RPMS/noarch/clamav-data-0.102.2-4.el7.noarch.rpm \
           ~/rpmbuild/RPMS/noarch/clamav-filesystem-0.102.2-4.el7.noarch.rpm

(6) clamonacc が開発環境でコンパイルした curl ライブラリを参照する設定になっていることを確認します。

# objdump -p /usr/bin/clamonacc | grep curl
  NEEDED               libcurl.so.4
  RPATH                /usr/local/curl-7.69.1/lib

(7) 本番環境で必要な設定をしてから clamonacc を起動します。

# sed -i -e 's/^#TCP/TCP/' /etc/clamd.d/scan.conf
# systemctl start clamd@scan
# /usr/bin/clamonacc
posted by 熊猫さくら at 13:28| Comment(0) | TrackBack(0) | Linux
この記事へのコメント
コメントを書く
お名前:

メールアドレス:

ホームページアドレス:

コメント:

※ブログオーナーが承認したコメントのみ表示されます。
この記事へのトラックバックURL
http://blog.sakura.ne.jp/tb/187355182
※ブログオーナーが承認したトラックバックのみ表示されます。

この記事へのトラックバック