Gentooのlogwatchがエラーになっていたので無理やり修正した

Gentooでインストールしたlogwatchが結構前からエラーになっていたので修正しました。エラーは結構前からだったんだけど、こんな内容。

 --------------------- httpd Begin ------------------------

 Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\G%{ <-- HERE Referer}i/ at /usr/share/logwatch/scripts/services/http line 313.
 Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\G%{ <-- HERE User-Agent}i/ at /usr/share/logwatch/scripts/services/http line 316.

 ---------------------- httpd End -------------------------

とりあえず前のバージョンに戻したら治るかなー、って思ってlogwatchの選択肢を確認。

# equery l -p logwatch
 * Searching for logwatch ...
[IP-] [  ] sys-apps/logwatch-7.4.0_p170-r1:0
[-P-] [ ~] sys-apps/logwatch-7.4.2:0
[-P-] [ ~] sys-apps/logwatch-7.4.3:0

ないね。今入っているのは一番上の7.4.0系。キーワード設定して新しいバージョンを入れるのも有りかもだけど、保守的にバージョンアップは避けることにしました。

仕方がないので問題のファイルを確認。エラーの内容的にも「エスケープしていない左のカッコが・・・」みたいな話だったので、直接修正してみました。

# diff http /usr/share/logwatch/scripts/services/http -u
--- http	2016-11-08 23:55:04.144740635 +0900
+++ /usr/share/logwatch/scripts/services/http	2016-11-08 23:55:26.928216187 +0900
@@ -310,10 +310,10 @@
    } elsif ($logformat =~ /\G%O/gc) {
       $parse_field[$parse_index][$parse_subindex++] = "bytes_out";
       $parse_string[$parse_index] .= "(-|\\d*)";
-   } elsif ($logformat =~ /\G%{Referer}i/gci) {
+   } elsif ($logformat =~ /\G%\{Referer\}i/gci) {
       $parse_string[$parse_index] .= "(.*)";
       $parse_field[$parse_index][$parse_subindex++] = "referrer";
-   } elsif ($logformat =~ /\G%{User-Agent}i/gci) {
+   } elsif ($logformat =~ /\G%\{User-Agent\}i/gci) {
       $parse_string[$parse_index] .= "(.*)";
       $parse_field[$parse_index][$parse_subindex++] = "agent";
    } elsif ($logformat =~ /\G%({.*?})?./gc) {

もちろんだけど、右のカッコもエスケープしてあげました。

そしてコマンドラインから叩いて動作確認。

# /usr/sbin/logwatch.pl

大丈夫そうです。