From c768980784fb87fcde0d40ed56fcd2bf53d8914a Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Thu, 22 Mar 2007 22:17:41 +0000 Subject: [PATCH 1/9] - Close opened handlers. Thanks to Yaroslav Halchenko git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@563 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- server/server.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/server.py b/server/server.py index aa481045..f49a967d 100644 --- a/server/server.py +++ b/server/server.py @@ -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 From fddce1cbdc3c2ce95b7155dc27fcb524ec3c2119 Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Thu, 22 Mar 2007 22:18:46 +0000 Subject: [PATCH 2/9] - Clean up resources. Does not seem to free resources correctly. Gamin bug??? git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@564 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- server/filtergamin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/filtergamin.py b/server/filtergamin.py index d0f8adcb..bb5b00b3 100644 --- a/server/filtergamin.py +++ b/server/filtergamin.py @@ -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 From f260372bb2005508d083ecc67d672ddcc4ff686a Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Thu, 22 Mar 2007 22:20:36 +0000 Subject: [PATCH 3/9] - Updated git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@565 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- CHANGELOG | 6 +++++- common/version.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 29302ebe..f2a5b6bc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,9 +4,13 @@ |_| \__,_|_|_/___|_.__/\__,_|_||_| ============================================================= -Fail2Ban (version 0.7.8) 2007/03/21 +Fail2Ban (version 0.?.?) 2007/??/?? ============================================================= +ver. 0.?.? (2007/??/??) - ??? +---------- +- Close opened handlers. Thanks to Yaroslav Halchenko + ver. 0.7.8 (2007/03/21) - release candidate ---------- - Fixed asctime pattern in datedetector.py diff --git a/common/version.py b/common/version.py index e5f3d7c3..223a4cb8 100644 --- a/common/version.py +++ b/common/version.py @@ -24,4 +24,4 @@ __date__ = "$Date$" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -version = "0.7.8" +version = "0.7.8-SVN" From b40b9d88d290d1b8422e92f42b1e40385ef6712d Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Mon, 26 Mar 2007 21:08:09 +0000 Subject: [PATCH 4/9] - Added a new line before "Regards," git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@566 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- config/action.d/mail-buffered.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/action.d/mail-buffered.conf b/config/action.d/mail-buffered.conf index 6be60a63..fb2eb4da 100644 --- a/config/action.d/mail-buffered.conf +++ b/config/action.d/mail-buffered.conf @@ -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 From 090518ddafe77e6b586ca555a62ff5064ea1925a Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Mon, 26 Mar 2007 21:17:31 +0000 Subject: [PATCH 5/9] - Fixed "reload" bug. Many many thanks to Yaroslav Halchenko git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@567 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- CHANGELOG | 1 + server/actions.py | 4 ++-- server/filter.py | 2 +- server/filtergamin.py | 2 +- server/filterpoll.py | 2 +- server/jail.py | 8 ++++---- server/jailthread.py | 2 +- server/server.py | 8 ++++---- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f2a5b6bc..52d7da11 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ Fail2Ban (version 0.?.?) 2007/??/?? ver. 0.?.? (2007/??/??) - ??? ---------- - Close opened handlers. Thanks to Yaroslav Halchenko +- Fixed "reload" bug. Many many thanks to Yaroslav Halchenko ver. 0.7.8 (2007/03/21) - release candidate ---------- diff --git a/server/actions.py b/server/actions.py index a332a46c..06f15ec6 100644 --- a/server/actions.py +++ b/server/actions.py @@ -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/filter.py b/server/filter.py index ed63299d..131c6d02 100644 --- a/server/filter.py +++ b/server/filter.py @@ -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 bb5b00b3..37b8d488 100644 --- a/server/filtergamin.py +++ b/server/filtergamin.py @@ -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. diff --git a/server/filterpoll.py b/server/filterpoll.py index 3afd587f..a13f9e71 100644 --- a/server/filterpoll.py +++ b/server/filterpoll.py @@ -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 00d0b96c..363097a6 100644 --- a/server/jail.py +++ b/server/jail.py @@ -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 8a3c6d30..44667ff0 100644 --- a/server/jailthread.py +++ b/server/jailthread.py @@ -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 f49a967d..832cfaa7 100644 --- a/server/server.py +++ b/server/server.py @@ -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) From 6145a88fe872aee1c78e6a2541db472c33b823da Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Sun, 1 Apr 2007 20:42:05 +0000 Subject: [PATCH 6/9] - Added date format for asctime without year git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@568 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- CHANGELOG | 1 + server/datedetector.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 52d7da11..8ad146ee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ ver. 0.?.? (2007/??/??) - ??? ---------- - Close opened handlers. Thanks to Yaroslav Halchenko - Fixed "reload" bug. Many many thanks to Yaroslav Halchenko +- Added date format for asctime without year ver. 0.7.8 (2007/03/21) - release candidate ---------- diff --git a/server/datedetector.py b/server/datedetector.py index 6c475c75..6b9986f5 100644 --- a/server/datedetector.py +++ b/server/datedetector.py @@ -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") From ac54c8b4f1ad6c0ca0d5de014f474f596d898f66 Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Wed, 18 Apr 2007 20:22:54 +0000 Subject: [PATCH 7/9] - Modified filters config. Thanks to Michael C. Haller git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@569 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- CHANGELOG | 1 + config/filter.d/apache-auth.conf | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 8ad146ee..9dab34e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ ver. 0.?.? (2007/??/??) - ??? - 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 ver. 0.7.8 (2007/03/21) - release candidate ---------- diff --git a/config/filter.d/apache-auth.conf b/config/filter.d/apache-auth.conf index 87d6edef..20553d91 100644 --- a/config/filter.d/apache-auth.conf +++ b/config/filter.d/apache-auth.conf @@ -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. From bfab0409a2012c0b06d6b2ab0f3c1585f7748e3b Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Thu, 19 Apr 2007 21:43:45 +0000 Subject: [PATCH 8/9] - Replaced -d with -f. We are looking for a file, not a directory git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@570 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- CHANGELOG | 1 + config/action.d/mail-buffered.conf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9dab34e6..eedf5848 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ ver. 0.?.? (2007/??/??) - ??? - 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 ---------- diff --git a/config/action.d/mail-buffered.conf b/config/action.d/mail-buffered.conf index fb2eb4da..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 ` From b813cc58b9a7d8deb8a81daba07a6fc0b7124a16 Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Thu, 19 Apr 2007 21:57:27 +0000 Subject: [PATCH 9/9] - Prepared release 0.7.9 git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@571 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- CHANGELOG | 4 ++-- README | 9 +++++---- common/version.py | 2 +- man/fail2ban-client.1 | 4 ++-- man/fail2ban-regex.1 | 4 ++-- man/fail2ban-server.1 | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index eedf5848..c273e929 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,10 +4,10 @@ |_| \__,_|_|_/___|_.__/\__,_|_||_| ============================================================= -Fail2Ban (version 0.?.?) 2007/??/?? +Fail2Ban (version 0.7.9) 2007/04/19 ============================================================= -ver. 0.?.? (2007/??/??) - ??? +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 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 223a4cb8..104ae403 100644 --- a/common/version.py +++ b/common/version.py @@ -24,4 +24,4 @@ __date__ = "$Date$" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -version = "0.7.8-SVN" +version = "0.7.9" 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