diff --git a/CHANGELOG b/CHANGELOG index 29302ebe..c273e929 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,9 +4,17 @@ |_| \__,_|_|_/___|_.__/\__,_|_||_| ============================================================= -Fail2Ban (version 0.7.8) 2007/03/21 +Fail2Ban (version 0.7.9) 2007/04/19 ============================================================= +ver. 0.7.9 (2007/04/19) - release candidate +---------- +- Close opened handlers. Thanks to Yaroslav Halchenko +- Fixed "reload" bug. Many many thanks to Yaroslav Halchenko +- Added date format for asctime without year +- Modified filters config. Thanks to Michael C. Haller +- Fixed a small bug in mail-buffered.conf + ver. 0.7.8 (2007/03/21) - release candidate ---------- - Fixed asctime pattern in datedetector.py diff --git a/PKG-INFO b/PKG-INFO index c7fc4b85..993bbcf8 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: fail2ban -Version: 0.7.8 +Version: 0.7.9 Summary: Ban IPs that make too many password failure Home-page: http://fail2ban.sourceforge.net Author: Cyril Jaquier diff --git a/README b/README index d73b72d9..22262f4b 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ |_| \__,_|_|_/___|_.__/\__,_|_||_| ============================================================= -Fail2Ban (version 0.7.8) 2007/03/21 +Fail2Ban (version 0.7.9) 2007/04/19 ============================================================= Fail2Ban scans log files like /var/log/pwdfail and bans IP @@ -28,8 +28,8 @@ Optional: To install, just do: -> tar xvfj fail2ban-0.7.8.tar.bz2 -> cd fail2ban-0.7.8 +> tar xvfj fail2ban-0.7.9.tar.bz2 +> cd fail2ban-0.7.9 > python setup.py install This will install Fail2Ban into /usr/share/fail2ban. The @@ -73,7 +73,8 @@ Tom Pike, Iain Lea, Andrey G. Grozin, Yaroslav Halchenko, Jonathan Kamens, Stephen Gildea, Markus Hoffmann, Mark Edgington, Patrick Börjesson, kojiro, zugeschmiert, Tyler, Nick Munger, Christoph Haas, Justin Shore, Joël Bertrand, -René Berber, mEDI, Axel Thimm, Eric Gerbier, Christian Rauch +René Berber, mEDI, Axel Thimm, Eric Gerbier, Christian Rauch, +Michael C. Haller License: -------- diff --git a/common/version.py b/common/version.py index 81c1218a..e21b11b4 100644 --- a/common/version.py +++ b/common/version.py @@ -16,12 +16,12 @@ # Author: Cyril Jaquier # -# $Revision: 561 $ +# $Revision: 571 $ __author__ = "Cyril Jaquier" -__version__ = "$Revision: 561 $" -__date__ = "$Date: 2007-03-21 22:44:07 +0100 (Wed, 21 Mar 2007) $" +__version__ = "$Revision: 571 $" +__date__ = "$Date: 2007-04-19 23:57:27 +0200 (Thu, 19 Apr 2007) $" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -version = "0.7.8" +version = "0.7.9" diff --git a/config/action.d/mail-buffered.conf b/config/action.d/mail-buffered.conf index 6be60a63..973d48ec 100644 --- a/config/action.d/mail-buffered.conf +++ b/config/action.d/mail-buffered.conf @@ -21,7 +21,7 @@ actionstart = echo -en "Hi,\n # Notes.: command executed once at the end of Fail2Ban # Values: CMD # -actionstop = if [ -d ]; then +actionstop = if [ -f ]; then echo -en "Hi,\n These hosts have been banned by Fail2Ban.\n `cat ` @@ -54,7 +54,7 @@ actionban = echo `date`": ( failures)" >> echo -en "Hi,\n These hosts have been banned by Fail2Ban.\n `cat ` - Regards,\n + \nRegards,\n Fail2Ban"|mail -s "[Fail2Ban] : Summary" rm fi diff --git a/config/filter.d/apache-auth.conf b/config/filter.d/apache-auth.conf index f333ec01..b010cea8 100644 --- a/config/filter.d/apache-auth.conf +++ b/config/filter.d/apache-auth.conf @@ -2,7 +2,7 @@ # # Author: Cyril Jaquier # -# $Revision: 495 $ +# $Revision: 569 $ # [Definition] @@ -14,7 +14,9 @@ # (?:::f{4,6}:)?(?P\S+) # Values: TEXT # -failregex = [[]client []] user .*(?:: authentication failure|not found) +failregex = [[]client []] user .* authentication failure + [[]client []] user .* not found + [[]client []] user .* password mismatch # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. diff --git a/man/fail2ban-client.1 b/man/fail2ban-client.1 index 8b396854..2c4f7205 100644 --- a/man/fail2ban-client.1 +++ b/man/fail2ban-client.1 @@ -1,11 +1,11 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. -.TH FAIL2BAN-CLIENT "1" "February 2007" "fail2ban-client v0.7.7" "User Commands" +.TH FAIL2BAN-CLIENT "1" "April 2007" "fail2ban-client v0.7.9" "User Commands" .SH NAME fail2ban-client \- configure and control the server .SH DESCRIPTION [?1034hUsage: ../fail2ban\-client [OPTIONS] .PP -Fail2Ban v0.7.7 reads log file that contains password failure report +Fail2Ban v0.7.9 reads log file that contains password failure report and bans the corresponding IP addresses using firewall rules. .SH OPTIONS .TP diff --git a/man/fail2ban-regex.1 b/man/fail2ban-regex.1 index d9e8ef0f..1d772cbb 100644 --- a/man/fail2ban-regex.1 +++ b/man/fail2ban-regex.1 @@ -1,12 +1,12 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. -.TH FAIL2BAN-REGEX "1" "February 2007" "fail2ban-regex v0.7.7" "User Commands" +.TH FAIL2BAN-REGEX "1" "April 2007" "fail2ban-regex v0.7.9" "User Commands" .SH NAME fail2ban-regex \- test Fail2ban "failregex" option .SH SYNOPSIS .B fail2ban-regex [\fIOPTIONS\fR] \fI \fR .SH DESCRIPTION -Fail2Ban v0.7.7 reads log file that contains password failure report +Fail2Ban v0.7.9 reads log file that contains password failure report and bans the corresponding IP addresses using firewall rules. .PP This tools can test regular expressions for "fail2ban". diff --git a/man/fail2ban-server.1 b/man/fail2ban-server.1 index dc79c090..46efd735 100644 --- a/man/fail2ban-server.1 +++ b/man/fail2ban-server.1 @@ -1,12 +1,12 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. -.TH FAIL2BAN-SERVER "1" "February 2007" "fail2ban-server v0.7.7" "User Commands" +.TH FAIL2BAN-SERVER "1" "April 2007" "fail2ban-server v0.7.9" "User Commands" .SH NAME fail2ban-server \- start the server .SH SYNOPSIS .B fail2ban-server [\fIOPTIONS\fR] .SH DESCRIPTION -Fail2Ban v0.7.7 reads log file that contains password failure report +Fail2Ban v0.7.9 reads log file that contains password failure report and bans the corresponding IP addresses using firewall rules. .PP Only use this command for debugging purpose. Start the server with diff --git a/server/actions.py b/server/actions.py index ca9d3eaf..c166f44f 100644 --- a/server/actions.py +++ b/server/actions.py @@ -16,11 +16,11 @@ # Author: Cyril Jaquier # -# $Revision: 556 $ +# $Revision: 567 $ __author__ = "Cyril Jaquier" -__version__ = "$Revision: 556 $" -__date__ = "$Date: 2007-03-07 21:54:32 +0100 (Wed, 07 Mar 2007) $" +__version__ = "$Revision: 567 $" +__date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" @@ -125,10 +125,10 @@ class Actions(JailThread): # @return True when the thread exits nicely def run(self): + self.setActive(True) for action in self.__actions: action.execActionStart() - self.setActive(True) - while self.isActive(): + while self._isActive(): if not self.getIdle(): #logSys.debug(self.jail.getName() + ": action") ret = self.__checkBan() diff --git a/server/datedetector.py b/server/datedetector.py index b24d01cc..127dc2c2 100644 --- a/server/datedetector.py +++ b/server/datedetector.py @@ -16,11 +16,11 @@ # Author: Cyril Jaquier # -# $Revision: 553 $ +# $Revision: 568 $ __author__ = "Cyril Jaquier" -__version__ = "$Revision: 553 $" -__date__ = "$Date: 2007-02-26 00:53:22 +0100 (Mon, 26 Feb 2007) $" +__version__ = "$Revision: 568 $" +__date__ = "$Date: 2007-04-01 22:42:05 +0200 (Sun, 01 Apr 2007) $" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" @@ -56,6 +56,12 @@ class DateDetector: template.setRegex("\S{3} \S{3}\s{1,2}\d{1,2} \d{2}:\d{2}:\d{2} \d{4}") template.setPattern("%a %b %d %H:%M:%S %Y") self.__templates.append(template) + # asctime without year + template = DateStrptime() + template.setName("Weekday Month Day Hour:Minute:Second") + template.setRegex("\S{3} \S{3}\s{1,2}\d{1,2} \d{2}:\d{2}:\d{2}") + template.setPattern("%a %b %d %H:%M:%S") + self.__templates.append(template) # simple date template = DateStrptime() template.setName("Year/Month/Day Hour:Minute:Second") diff --git a/server/filter.py b/server/filter.py index ce3fefeb..f3330938 100644 --- a/server/filter.py +++ b/server/filter.py @@ -16,11 +16,11 @@ # Author: Cyril Jaquier # -# $Revision: 537 $ +# $Revision: 567 $ __author__ = "Cyril Jaquier" -__version__ = "$Revision: 537 $" -__date__ = "$Date: 2007-02-01 21:50:12 +0100 (Thu, 01 Feb 2007) $" +__version__ = "$Revision: 567 $" +__date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" @@ -385,7 +385,7 @@ class Filter(JailThread): self.__setFilePos() lastLine = None for line in self.__crtHandler: - if not self.isActive(): + if not self._isActive(): # The jail has been stopped break try: diff --git a/server/filtergamin.py b/server/filtergamin.py index 807d7930..2cc91b11 100644 --- a/server/filtergamin.py +++ b/server/filtergamin.py @@ -16,11 +16,11 @@ # Author: Cyril Jaquier # -# $Revision: 451 $ +# $Revision: 567 $ __author__ = "Cyril Jaquier" -__version__ = "$Revision: 451 $" -__date__ = "$Date: 2006-11-06 23:47:24 +0100 (Mon, 06 Nov 2006) $" +__version__ = "$Revision: 567 $" +__date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" @@ -99,7 +99,7 @@ class FilterGamin(Filter): def run(self): self.setActive(True) - while self.isActive(): + while self._isActive(): if not self.getIdle(): # We cannot block here because we want to be able to # exit. @@ -117,5 +117,15 @@ class FilterGamin(Filter): time.sleep(self.getSleepTime()) else: time.sleep(self.getSleepTime()) + # Cleanup Gamin + self.__cleanup() logSys.debug(self.jail.getName() + ": filter terminated") return True + + ## + # Desallocates the resources used by Gamin. + + def __cleanup(self): + for path in Filter.getLogPath(self): + self.monitor.stop_watch(path) + del self.monitor diff --git a/server/filterpoll.py b/server/filterpoll.py index 7e3a3b2c..8f760c20 100644 --- a/server/filterpoll.py +++ b/server/filterpoll.py @@ -16,11 +16,11 @@ # Author: Cyril Jaquier # -# $Revision: 504 $ +# $Revision: 567 $ __author__ = "Cyril Jaquier" -__version__ = "$Revision: 504 $" -__date__ = "$Date: 2006-12-23 17:37:17 +0100 (Sat, 23 Dec 2006) $" +__version__ = "$Revision: 567 $" +__date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" @@ -93,7 +93,7 @@ class FilterPoll(Filter): def run(self): self.setActive(True) - while self.isActive(): + while self._isActive(): if not self.getIdle(): # Get file modification for f in self.getLogPath(): diff --git a/server/jail.py b/server/jail.py index 1f415d86..1d006de3 100644 --- a/server/jail.py +++ b/server/jail.py @@ -16,11 +16,11 @@ # Author: Cyril Jaquier # -# $Revision: 452 $ +# $Revision: 567 $ __author__ = "Cyril Jaquier" -__version__ = "$Revision: 452 $" -__date__ = "$Date: 2006-11-06 23:48:46 +0100 (Mon, 06 Nov 2006) $" +__version__ = "$Revision: 567 $" +__date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" @@ -89,10 +89,10 @@ class Jail: self.__filter.join() self.__action.join() - def isActive(self): - isActive0 = self.__filter.isActive() - isActive1 = self.__action.isActive() - return isActive0 or isActive1 + def isAlive(self): + isAlive0 = self.__filter.isAlive() + isAlive1 = self.__action.isAlive() + return isAlive0 or isAlive1 def setIdle(self, value): self.__filter.setIdle(value) diff --git a/server/jailthread.py b/server/jailthread.py index 2c9734d6..4fa74c13 100644 --- a/server/jailthread.py +++ b/server/jailthread.py @@ -16,11 +16,11 @@ # Author: Cyril Jaquier # -# $Revision: 433 $ +# $Revision: 567 $ __author__ = "Cyril Jaquier" -__version__ = "$Revision: 433 $" -__date__ = "$Date: 2006-10-24 21:40:51 +0200 (Tue, 24 Oct 2006) $" +__version__ = "$Revision: 567 $" +__date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" @@ -105,7 +105,7 @@ class JailThread(Thread): # Check if the filter thread is running. # @return True if the thread is running - def isActive(self): + def _isActive(self): return self.__isRunning ## diff --git a/server/server.py b/server/server.py index 3c424f1d..4b043abd 100644 --- a/server/server.py +++ b/server/server.py @@ -16,11 +16,11 @@ # Author: Cyril Jaquier # -# $Revision: 503 $ +# $Revision: 567 $ __author__ = "Cyril Jaquier" -__version__ = "$Revision: 503 $" -__date__ = "$Date: 2006-12-23 17:31:00 +0100 (Sat, 23 Dec 2006) $" +__version__ = "$Revision: 567 $" +__date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" @@ -96,7 +96,7 @@ class Server: def startJail(self, name): try: self.__lock.acquire() - if not self.isActive(name): + if not self.isAlive(name): self.__jails.get(name).start() finally: self.__lock.release() @@ -104,7 +104,7 @@ class Server: def stopJail(self, name): try: self.__lock.acquire() - if self.isActive(name): + if self.isAlive(name): self.__jails.get(name).stop() self.delJail(name) finally: @@ -118,8 +118,8 @@ class Server: finally: self.__lock.release() - def isActive(self, name): - return self.__jails.get(name).isActive() + def isAlive(self, name): + return self.__jails.get(name).isAlive() def setIdleJail(self, name, value): self.__jails.get(name).setIdle(value) @@ -326,15 +326,18 @@ class Server: else: # Target should be a file try: - open(target, "a") + open(target, "a").close() hdlr = logging.FileHandler(target) except IOError: logSys.error("Unable to log to " + target) logSys.info("Logging to previous target " + self.__logTarget) return False self.__logTarget = target - # Remove previous handler - logging.getLogger("fail2ban").handlers = [] + # Removes previous handlers + for handler in logging.getLogger("fail2ban").handlers: + # Closes the handler. + handler.close() + logging.getLogger("fail2ban").removeHandler(handler) # set a format which is simpler for console use formatter = logging.Formatter("%(asctime)s %(name)-16s: %(levelname)-6s %(message)s") # tell the handler to use this format