rspamd と rmilter をアップデート

ここ 2 年半ぐらい、rspamd を使い続けているサーバ、動作上特に不満があるわけでもなかったのだけど、

以前、インストールメモをエントリーとしてあげていた、 rspamdrmilter の組み合わせ、なかなか調子良く動作してくれている。

[From rspamd + rmiter の組み合わせに、ClamAV を連携させてみた - Soukaku's HENA-CHOKO Blog]

2週間ほど前から、そのサーバが受信・配送したメールに Spam がチラホラ紛れ込んでくるようになったので、「こりゃ自前でフィルタ書かんと駄目かな~」と思いつつ、公式サイトをチェックしてしてみたら…。

Rspamd is also available in some versions of Debian and Ubuntu. However, we are looking for an active maintainer for rspamd in these ‘official’ repos, as now rspamd is terribly outdated there.

Please DO NOT use those packages, as they are no longer supported.

[From Downloads]

「パッケージ、アップデートされねぇなぁ、 sid なのに…」とは感じてたんですけどね、「メンテナ探してるんだけど、 Debian/Ubuntu の公式サイトで配布してるのは古いんで使わないでね。」という状況だったはつゆ知らず…。

ということでフィルタを書く前に、公式サイトに書いてある手順を元に、最新バージョンの rspamd / rmilter にアップデートしてみた。

ということで、以下作業手順とログ

まず、現時点で、インストール済みのバージョンは、以下の通り。

root@vps2:~# dpkg -l rspamd rmilter
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==================-==============-==============-=========================================
hi rmilter 1.6.3 amd64 Another sendmail milter for different mai hi rspamd 0.9.9+b1 amd64 Rapid spam filtering system

公式サイトで見ると、 rspamd は 1.4.4 、rmilter は 1.10 が最新のようなので、随分とバージョンが上がってますね…。


アップデートの手順自体は、公式サイトの Downloads にある Debian/Ubuntu の手順に従って、 rspamd をダウンロードするための apt ラインを設定すればいいわけですが、自分のところの場合、この状態で "aptitude update" を実行するとエラーが出てパッケージDBの更新ができない。

rroot@vps2:~# wget -O- https://rspamd.com/apt-stable/gpg.key | apt-key add -
--2017-02-27 21:05:47-- https://rspamd.com/apt-stable/gpg.key
Resolving rspamd.com (rspamd.com)... 5.9.155.182
Connecting to rspamd.com (rspamd.com)|5.9.155.182|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3140 (3.1K) [text/plain]
Saving to: 'STDOUT'

- 100%[===============================>] 3.07K --.-KB/s in 0s

2017-02-27 21:05:48 (84.1 MB/s) - written to stdout [3140/3140]

OK
root@vps2:~# echo "deb http://rspamd.com/apt-stable/ $CODENAME main" > /etc/apt/sources.list.d/rspamd.list
root@vps2:~# echo "deb-src http://rspamd.com/apt-stable/ $CODENAME main" >> /etc/apt/sources.list.d/rspamd.list
root@vps2:~# aptitude update
Hit http://debian-mirror.sakura.ne.jp/debian sid InRelease
Ign http://debian-mirror.sakura.ne.jp/debian stable InRelease
Hit http://debian-mirror.sakura.ne.jp/debian experimental InRelease
Hit http://debian-mirror.sakura.ne.jp/debian stable Release
Ign http://download.webmin.com/download/repository sarge InRelease
Ign http://rspamd.com/apt-stable stretch InRelease
Ign http://download.owncloud.org/download/repositories/stable/Debian_8.0 InRelease
Hit http://download.webmin.com/download/repository sarge Release
Err http://rspamd.com/apt-stable stretch Release
404 Not Found
Hit http://download.owncloud.org/download/repositories/stable/Debian_8.0 Release
Hit https://packagecloud.io/grafana/stable/debian jessie InRelease
E: The repository 'http://rspamd.com/apt-stable stretch Release' does not have a Release file.
E: Failed to download some files
W: Failed to fetch http://rspamd.com/apt-stable/dists/stretch/Release: 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.

エラーをよく見てみると "http://rspamd.com/apt-stable/dists/stretch/Release: 404 Not Found" とあるので、この辺りが違ってそう、ということでサイト側を確認してみたところ、 stretch がない。

https://rspamd.com/apt-stable/dists/ 以下のディレクトリ構成

うちの場合は sid を使っているので "/etc/apt/sources.list.d/rspamd.list" の中の stretch を sid に置き換えてあげれば OK。

root@vps2:~# diff -u /etc/apt/sources.list.d/rspamd.list~ /etc/apt/sources.list.d/rspamd.list
--- /etc/apt/sources.list.d/rspamd.list~ 2017-02-27 21:05:50.590960052 +0900
+++ /etc/apt/sources.list.d/rspamd.list 2017-02-27 21:19:01.790854483 +0900
@@ -1,2 +1,2 @@
-deb http://rspamd.com/apt-stable/ stretch main
-deb-src http://rspamd.com/apt-stable/ stretch main
+deb http://rspamd.com/apt-stable/ sid main
+deb-src http://rspamd.com/apt-stable/ sid main

この状態で、パッケージDBのアップデートをしてから、おもむろに rspamd と rmilter のパッケージアップデートを実行。

root@vps2:~# aptitude safe-upgrade rspamd rmilter
Resolving dependencies...
The following NEW packages will be installed:
libfann2{a} libopendkim11{a}
The following packages will be REMOVED:
libspf2-2{u}
The following packages will be upgraded:
rmilter rspamd
2 packages upgraded, 2 newly installed, 1 to remove and 10 not upgraded.
Need to get 3826 kB of archives. After unpacking 21.3 MB will be used.
Do you want to continue? [Y/n/?] y
Get: 1 http://debian-mirror.sakura.ne.jp/debian sid/main amd64 libopendkim11 amd64 2.11.0~alpha-9 [91.1 kB]
Get: 2 http://debian-mirror.sakura.ne.jp/debian sid/main amd64 libfann2 amd64 2.2.0+ds-3 [66.1 kB]
Get: 3 http://rspamd.com/apt-stable sid/main amd64 rmilter amd64 1.10.0-2~sid [243 kB]
Get: 4 http://rspamd.com/apt-stable sid/main amd64 rspamd amd64 1.4.4-2~sid [3426 kB]
Fetched 3826 kB in 3s (977 kB/s)
Reading changelogs... Done
Selecting previously unselected package libopendkim11.
(Reading database ... 153577 files and directories currently installed.)
Preparing to unpack .../libopendkim11_2.11.0~alpha-9_amd64.deb ...
Unpacking libopendkim11 (2.11.0~alpha-9) ...
Preparing to unpack .../rmilter_1.10.0-2~sid_amd64.deb ...
No rmilter found running; none killed.
Unpacking rmilter (1.10.0-2~sid) over (1.6.3) ...
(Reading database ... 153579 files and directories currently installed.)
Removing libspf2-2 (1.2.10-7+b1) ...
Selecting previously unselected package libfann2:amd64.
(Reading database ... 153575 files and directories currently installed.)
Preparing to unpack .../libfann2_2.2.0+ds-3_amd64.deb ...
Unpacking libfann2:amd64 (2.2.0+ds-3) ...
Preparing to unpack .../rspamd_1.4.4-2~sid_amd64.deb ...
Unpacking rspamd (1.4.4-2~sid) over (0.9.9+b1) ...
dpkg: warning: unable to delete old directory '/etc/rspamd/lua/regexp': Directory not empty
dpkg: warning: unable to delete old directory '/etc/rspamd/lua': Directory not empty
Setting up libopendkim11 (2.11.0~alpha-9) ...
Setting up rmilter (1.10.0-2~sid) ...
Installing new version of config file /etc/init.d/rmilter ...

Configuration file '/etc/rmilter.conf'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** rmilter.conf (Y/I/N/O/D/Z) [default=N] ?

Configuration file '/etc/rmilter.conf.common'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** rmilter.conf.common (Y/I/N/O/D/Z) [default=N] ?

Configuration file '/etc/rmilter.conf.sysvinit'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** rmilter.conf.sysvinit (Y/I/N/O/D/Z) [default=N] ?
process already running.
Created symlink /etc/systemd/system/multi-user.target.wants/rmilter.service -> /lib/systemd/system/rmilter.service.
process already running.
Setting up libfann2:amd64 (2.2.0+ds-3) ...
Processing triggers for libc-bin (2.24-9) ...
Processing triggers for systemd (232-18) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up rspamd (1.4.4-2~sid) ...
Installing new version of config file /etc/init.d/rspamd ...
Installing new version of config file /etc/rspamd/2tld.inc ...
Installing new version of config file /etc/rspamd/common.conf ...
Installing new version of config file /etc/rspamd/composites.conf ...
Installing new version of config file /etc/rspamd/logging.inc ...
Installing new version of config file /etc/rspamd/metrics.conf ...
Installing new version of config file /etc/rspamd/modules.conf ...
Installing new version of config file /etc/rspamd/options.inc ...
Installing new version of config file /etc/rspamd/rspamd.conf ...
Installing new version of config file /etc/rspamd/rspamd.sysvinit.conf ...
Installing new version of config file /etc/rspamd/statistic.conf ...

Configuration file '/etc/rspamd/surbl-whitelist.inc'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** surbl-whitelist.inc (Y/I/N/O/D/Z) [default=N] ?
Installing new version of config file /etc/rspamd/worker-normal.inc ...
Created symlink /etc/systemd/system/multi-user.target.wants/rspamd.service -> /lib/systemd/system/rspamd.service.
Processing triggers for systemd (232-18) ...

Current status: 10 (-2) upgradable.

途中、4 回ほど変更した設定ファイルをそのまま使うかどうか確認されるので、そこは全部 N (いいえ)と答えておけば、既存設定がそのまま適用されて、daemon の再起動までが完了〜。あとは、eicar のテストシグネチャをメールで送信しようとして、検知されれば、動作も問題なし、と。

root@vps2:~# swaks -f root@downtown.jp -t soukaku@downtown.jp -s 127.0.0.1 -d /var/www/eicar/eicar.com.txt
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<- 220 vps2.downtown.jp ESMTP Postfix (Debian/GNU)
-> EHLO vps2.downtown.jp
<- 250-vps2.downtown.jp
<- 250-PIPELINING
<- 250-SIZE 10240000
<- 250-VRFY
<- 250-ETRN
<- 250-STARTTLS
<- 250-ENHANCEDSTATUSCODES
<- 250-8BITMIME
<- 250-DSN
<- 250 SMTPUTF8
-> MAIL FROM:<root@downtown.jp>
<- 250 2.1.0 Ok
-> RCPT TO:<soukaku@downtown.jp>
<- 250 2.1.5 Ok
-> DATA
<- 354 End data with <CR><LF>.<CR><LF>
-> X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
-> .
<** 554 5.7.1 Infected: Eicar-Test-Signature(5f873d9dd8da2114f6dceffb05b27069:368)
-> QUIT
<- 221 2.0.0 Bye
=== Connection closed with remote host.

ということで、アップデート完了。

上手く行ったと思ったら…

無事終わったかと思ったのだけど、念のためログのチェックしていたら、rmilter がバージョン上がったことで spf をサポートしなくなったらしく、再起動に失敗しているログを発見。

Feb 27 22:21:17 vps2 rmilter[14010]: config file parse warning! line: 173, text: downtown.jp, reason: spf support is removed from rmilter
Feb 27 22:21:17 vps2 rmilter[14010]: config file </etc/rmilter.conf.common> parse error! line: 211, text: beanstalk, reason: syntax error
Feb 27 22:21:17 vps2 rmilter[14010]: yyparse: cannot parse config file, 1 error

エラーメッセージの指示通り、 /etc/rmilter.conf.common の 173 行目と 211行目からの1ブロックをコメント化して〜、とかやったのだけど、結構変更点が多いようなので、新しいバージョンに対応した /etc/rmilter.conf.common.dpkg-dist をベースに設定ファイルを書き直したり、と結構面倒なことになってしまいました…。orz

アップデートだけで結構な分量になってしまったので、フィルタについては別エントリーにて。バージョン上がったことで追加された機能もあるようなので、そのあたりの話もおいおい書いてきたいですね〜。

トラックバック(1)

rspamd をアップデートしたことで、使えるようなった機能があるので、いろいろと試してみよう アップデートだけで結構な分量になってしまったので、フィルタ... 続きを読む

コメントする