From f7064d36c576a81a5484b78380ec9d5bd3724afe Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 4 Jul 2006 03:03:45 +0000 Subject: [PATCH] fixed empty ip and somewhat fixed locale issue --- debian/changelog | 11 ++- debian/patches/00_empty_ip | 22 ++++++ debian/patches/00_locale_config | 128 ++++++++++++++++++++++++++++++++ debian/patches/00list | 2 + 4 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 debian/patches/00_empty_ip create mode 100644 debian/patches/00_locale_config diff --git a/debian/changelog b/debian/changelog index 47049a93..a9979fce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,17 @@ +fail2ban (0.6.1-10) unstable; urgency=low + + * Filtered out empty entries for ignoreip to reduce confusing WARNING log + message + * Added configuration parameter "locale" to specify LC_TIME for time + pattern matching (closes: #367990,363391) + + -- Yaroslav Halchenko Mon, 3 Jul 2006 21:59:34 -0400 + fail2ban (0.6.1-9) unstable; urgency=low * Adjusted rm commands in init script to don't use -r for removal of the pidfile (thanks Stephen Gran) - * Added clarification about multiport banning to README.Debian + * Added clarification about multiport banning to README.Debian (closes: #373592) -- Yaroslav Halchenko Wed, 14 Jun 2006 12:05:44 -0400 diff --git a/debian/patches/00_empty_ip b/debian/patches/00_empty_ip new file mode 100644 index 00000000..16b81646 --- /dev/null +++ b/debian/patches/00_empty_ip @@ -0,0 +1,22 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 00_empty_ip.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Filter out empty IPs for ignoreip + +@DPATCH@ + +diff -x '*~' -Naur fail2ban-0.6.1.pre/fail2ban.py fail2ban-0.6.1.post/fail2ban.py +--- fail2ban-0.6.1.pre/fail2ban.py 2006-03-19 00:20:44.000000000 -0500 ++++ fail2ban-0.6.1.post/fail2ban.py 2006-07-03 21:56:10.000000000 -0400 +@@ -356,7 +356,9 @@ + "ONLY DISPLAYED IN THE LOG MESSAGES") + + # Ignores IP list +- ignoreIPList = conf["ignoreip"].split(' ') ++ # and filter out empty entries. Otherwise ++ # WARNING: is not a valid IP address ++ ignoreIPList = filter(None, conf["ignoreip"].split(' ')) + + # Checks for root user. This is necessary because log files + # are owned by root and firewall needs root access. diff --git a/debian/patches/00_locale_config b/debian/patches/00_locale_config new file mode 100644 index 00000000..4d08aa27 --- /dev/null +++ b/debian/patches/00_locale_config @@ -0,0 +1,128 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 00_locale_config.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Set up LC_TIME per configuration option, not by resetting LC_ALL to +## DP: default locale as it was done before. So this patch effectively changes +## DP: bug into a feature + +@DPATCH@ + +diff -x '*~' -Naur fail2ban-0.6.1.pre/config/fail2ban.conf.hostsdeny fail2ban-0.6.1.post/config/fail2ban.conf.hostsdeny +--- fail2ban-0.6.1.pre/config/fail2ban.conf.hostsdeny 2006-03-27 12:56:38.000000000 -0500 ++++ fail2ban-0.6.1.post/config/fail2ban.conf.hostsdeny 2006-07-03 22:20:21.000000000 -0400 +@@ -11,6 +11,15 @@ + # + background = false + ++# Option: locale ++# Notes.: global (cannot be redefined per section) locale to use for ++# timestamp pattern matching by changing LC_TIME for ++# fail2ban process. Empty entry sets locale to default one ++# (usually specified by LC_ALL environment variable). ++# Values: LOCALE Default: ++# ++locale = ++ + # Option: logtargets + # Notes.: log targets. Space separated list of logging targets. + # Values: STDERR SYSLOG file Default: /var/log/fail2ban.log +diff -x '*~' -Naur fail2ban-0.6.1.pre/config/fail2ban.conf.iptables fail2ban-0.6.1.post/config/fail2ban.conf.iptables +--- fail2ban-0.6.1.pre/config/fail2ban.conf.iptables 2006-03-27 12:56:38.000000000 -0500 ++++ fail2ban-0.6.1.post/config/fail2ban.conf.iptables 2006-07-03 22:17:30.000000000 -0400 +@@ -28,6 +28,15 @@ + # + debug = false + ++# Option: locale ++# Notes.: global (cannot be redefined per section) locale to use for ++# timestamp pattern matching by changing LC_TIME for ++# fail2ban process. Empty entry sets locale to default one ++# (usually specified by LC_ALL environment variable). ++# Values: LOCALE Default: ++# ++locale = ++ + # Option: logtargets + # Notes.: log targets. Space separated list of logging targets. + # Values: STDERR SYSLOG file Default: /var/log/fail2ban.log +diff -x '*~' -Naur fail2ban-0.6.1.pre/config/fail2ban.conf.shorewall fail2ban-0.6.1.post/config/fail2ban.conf.shorewall +--- fail2ban-0.6.1.pre/config/fail2ban.conf.shorewall 2006-03-27 12:56:38.000000000 -0500 ++++ fail2ban-0.6.1.post/config/fail2ban.conf.shorewall 2006-07-03 22:20:01.000000000 -0400 +@@ -11,6 +11,15 @@ + # + background = false + ++# Option: locale ++# Notes.: global (cannot be redefined per section) locale to use for ++# timestamp pattern matching by changing LC_TIME for ++# fail2ban process. Empty entry sets locale to default one ++# (usually specified by LC_ALL environment variable). ++# Values: LOCALE Default: ++# ++locale = ++ + # Option: logtargets + # Notes.: log targets. Space separated list of logging targets. + # Values: STDERR SYSLOG file Default: /var/log/fail2ban.log +diff -x '*~' -Naur fail2ban-0.6.1.pre/fail2ban fail2ban-0.6.1.post/fail2ban +--- fail2ban-0.6.1.pre/fail2ban 2006-03-19 00:20:44.000000000 -0500 ++++ fail2ban-0.6.1.post/fail2ban 2006-07-03 22:38:11.000000000 -0400 +@@ -26,14 +26,7 @@ + __copyright__ = "Copyright (c) 2004 Cyril Jaquier" + __license__ = "GPL" + +-import sys, traceback, logging, locale +- +-# Set the locale with the user's default setting +-try: +- locale.setlocale(locale.LC_ALL, '') +-except Exception: +- print "Unable to set locale to " + `locale.getdefaultlocale()` +- sys.exit(-1) ++import sys, traceback, logging + + # Inserts our own modules path first in the list + # fix for bug #343821 +diff -x '*~' -Naur fail2ban-0.6.1.pre/fail2ban.py fail2ban-0.6.1.post/fail2ban.py +--- fail2ban-0.6.1.pre/fail2ban.py 2006-03-19 00:20:44.000000000 -0500 ++++ fail2ban-0.6.1.post/fail2ban.py 2006-07-03 23:02:03.000000000 -0400 +@@ -25,7 +25,8 @@ + __copyright__ = "Copyright (c) 2004 Cyril Jaquier" + __license__ = "GPL" + +-import time, sys, getopt, os, string, signal, logging, logging.handlers, copy ++import time, sys, getopt, os, string, signal, logging, logging.handlers, \ ++ copy, locale + from ConfigParser import * + + from version import version +@@ -240,6 +241,7 @@ + ["bool", "debug", False], + ["int", "verbose", conf["verbose"]], + ["str", "pidlock", "/var/run/fail2ban.pid"], ++ ["str", "locale", ""], + ["int", "maxfailures", 5], + ["int", "bantime", 600], + ["int", "findtime", 600], +@@ -262,10 +264,18 @@ + # have to be overridden + for t, label, v in optionValues: + confReader.setValue("DEFAULT", label, `conf[label]`) +- ++ + # PID lock + pidLock.setPath(conf["pidlock"]) +- ++ ++ # Set the LC_TIME with the user's default setting ++ try: ++ logSys.info("Setting LC_TIME locale option to '%s'"%conf["locale"]) ++ locale.setlocale(locale.LC_TIME, conf["locale"]) ++ except Exception: ++ logSys.error("Unable to set locale to '%s'"%conf["locale"]) ++ sys.exit(-1) ++ + # Now we can kill properly a running instance if needed + if conf["kill"]: + pid = pidLock.exists() diff --git a/debian/patches/00list b/debian/patches/00list index eb9074b2..d3003abd 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -2,3 +2,5 @@ 00_vsftpd_regexp 01_apache2_other 02_sasl_section +00_empty_ip +00_locale_config