Upgraded to fresh upstream 0.7.9

debian-upstream sdist/0.7.9
Yaroslav Halchenko 2007-10-16 17:01:22 -04:00
commit b6e07f1f3a
17 changed files with 91 additions and 61 deletions

View File

@ -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 ver. 0.7.8 (2007/03/21) - release candidate
---------- ----------
- Fixed asctime pattern in datedetector.py - Fixed asctime pattern in datedetector.py

View File

@ -1,6 +1,6 @@
Metadata-Version: 1.0 Metadata-Version: 1.0
Name: fail2ban Name: fail2ban
Version: 0.7.8 Version: 0.7.9
Summary: Ban IPs that make too many password failure Summary: Ban IPs that make too many password failure
Home-page: http://fail2ban.sourceforge.net Home-page: http://fail2ban.sourceforge.net
Author: Cyril Jaquier Author: Cyril Jaquier

9
README
View File

@ -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 Fail2Ban scans log files like /var/log/pwdfail and bans IP
@ -28,8 +28,8 @@ Optional:
To install, just do: To install, just do:
> tar xvfj fail2ban-0.7.8.tar.bz2 > tar xvfj fail2ban-0.7.9.tar.bz2
> cd fail2ban-0.7.8 > cd fail2ban-0.7.9
> python setup.py install > python setup.py install
This will install Fail2Ban into /usr/share/fail2ban. The 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 Jonathan Kamens, Stephen Gildea, Markus Hoffmann, Mark
Edgington, Patrick Börjesson, kojiro, zugeschmiert, Tyler, Edgington, Patrick Börjesson, kojiro, zugeschmiert, Tyler,
Nick Munger, Christoph Haas, Justin Shore, Joël Bertrand, 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: License:
-------- --------

View File

@ -16,12 +16,12 @@
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 561 $ # $Revision: 571 $
__author__ = "Cyril Jaquier" __author__ = "Cyril Jaquier"
__version__ = "$Revision: 561 $" __version__ = "$Revision: 571 $"
__date__ = "$Date: 2007-03-21 22:44:07 +0100 (Wed, 21 Mar 2007) $" __date__ = "$Date: 2007-04-19 23:57:27 +0200 (Thu, 19 Apr 2007) $"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
version = "0.7.8" version = "0.7.9"

View File

@ -21,7 +21,7 @@ actionstart = echo -en "Hi,\n
# Notes.: command executed once at the end of Fail2Ban # Notes.: command executed once at the end of Fail2Ban
# Values: CMD # Values: CMD
# #
actionstop = if [ -d <tmpfile> ]; then actionstop = if [ -f <tmpfile> ]; then
echo -en "Hi,\n echo -en "Hi,\n
These hosts have been banned by Fail2Ban.\n These hosts have been banned by Fail2Ban.\n
`cat <tmpfile>` `cat <tmpfile>`
@ -54,7 +54,7 @@ actionban = echo `date`": <ip> (<failures> failures)" >> <tmpfile>
echo -en "Hi,\n echo -en "Hi,\n
These hosts have been banned by Fail2Ban.\n These hosts have been banned by Fail2Ban.\n
`cat <tmpfile>` `cat <tmpfile>`
Regards,\n \nRegards,\n
Fail2Ban"|mail -s "[Fail2Ban] <name>: Summary" <dest> Fail2Ban"|mail -s "[Fail2Ban] <name>: Summary" <dest>
rm <tmpfile> rm <tmpfile>
fi fi

View File

@ -2,7 +2,7 @@
# #
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 495 $ # $Revision: 569 $
# #
[Definition] [Definition]
@ -14,7 +14,9 @@
# (?:::f{4,6}:)?(?P<host>\S+) # (?:::f{4,6}:)?(?P<host>\S+)
# Values: TEXT # Values: TEXT
# #
failregex = [[]client <HOST>[]] user .*(?:: authentication failure|not found) failregex = [[]client <HOST>[]] user .* authentication failure
[[]client <HOST>[]] user .* not found
[[]client <HOST>[]] user .* password mismatch
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -1,11 +1,11 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .\" 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 .SH NAME
fail2ban-client \- configure and control the server fail2ban-client \- configure and control the server
.SH DESCRIPTION .SH DESCRIPTION
[?1034hUsage: ../fail2ban\-client [OPTIONS] <COMMAND> [?1034hUsage: ../fail2ban\-client [OPTIONS] <COMMAND>
.PP .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. and bans the corresponding IP addresses using firewall rules.
.SH OPTIONS .SH OPTIONS
.TP .TP

View File

@ -1,12 +1,12 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .\" 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 .SH NAME
fail2ban-regex \- test Fail2ban "failregex" option fail2ban-regex \- test Fail2ban "failregex" option
.SH SYNOPSIS .SH SYNOPSIS
.B fail2ban-regex .B fail2ban-regex
[\fIOPTIONS\fR] \fI<LOG> <REGEX>\fR [\fIOPTIONS\fR] \fI<LOG> <REGEX>\fR
.SH DESCRIPTION .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. and bans the corresponding IP addresses using firewall rules.
.PP .PP
This tools can test regular expressions for "fail2ban". This tools can test regular expressions for "fail2ban".

View File

@ -1,12 +1,12 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .\" 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 .SH NAME
fail2ban-server \- start the server fail2ban-server \- start the server
.SH SYNOPSIS .SH SYNOPSIS
.B fail2ban-server .B fail2ban-server
[\fIOPTIONS\fR] [\fIOPTIONS\fR]
.SH DESCRIPTION .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. and bans the corresponding IP addresses using firewall rules.
.PP .PP
Only use this command for debugging purpose. Start the server with Only use this command for debugging purpose. Start the server with

View File

@ -16,11 +16,11 @@
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 556 $ # $Revision: 567 $
__author__ = "Cyril Jaquier" __author__ = "Cyril Jaquier"
__version__ = "$Revision: 556 $" __version__ = "$Revision: 567 $"
__date__ = "$Date: 2007-03-07 21:54:32 +0100 (Wed, 07 Mar 2007) $" __date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
@ -125,10 +125,10 @@ class Actions(JailThread):
# @return True when the thread exits nicely # @return True when the thread exits nicely
def run(self): def run(self):
self.setActive(True)
for action in self.__actions: for action in self.__actions:
action.execActionStart() action.execActionStart()
self.setActive(True) while self._isActive():
while self.isActive():
if not self.getIdle(): if not self.getIdle():
#logSys.debug(self.jail.getName() + ": action") #logSys.debug(self.jail.getName() + ": action")
ret = self.__checkBan() ret = self.__checkBan()

View File

@ -16,11 +16,11 @@
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 553 $ # $Revision: 568 $
__author__ = "Cyril Jaquier" __author__ = "Cyril Jaquier"
__version__ = "$Revision: 553 $" __version__ = "$Revision: 568 $"
__date__ = "$Date: 2007-02-26 00:53:22 +0100 (Mon, 26 Feb 2007) $" __date__ = "$Date: 2007-04-01 22:42:05 +0200 (Sun, 01 Apr 2007) $"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __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.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") template.setPattern("%a %b %d %H:%M:%S %Y")
self.__templates.append(template) 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 # simple date
template = DateStrptime() template = DateStrptime()
template.setName("Year/Month/Day Hour:Minute:Second") template.setName("Year/Month/Day Hour:Minute:Second")

View File

@ -16,11 +16,11 @@
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 537 $ # $Revision: 567 $
__author__ = "Cyril Jaquier" __author__ = "Cyril Jaquier"
__version__ = "$Revision: 537 $" __version__ = "$Revision: 567 $"
__date__ = "$Date: 2007-02-01 21:50:12 +0100 (Thu, 01 Feb 2007) $" __date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
@ -385,7 +385,7 @@ class Filter(JailThread):
self.__setFilePos() self.__setFilePos()
lastLine = None lastLine = None
for line in self.__crtHandler: for line in self.__crtHandler:
if not self.isActive(): if not self._isActive():
# The jail has been stopped # The jail has been stopped
break break
try: try:

View File

@ -16,11 +16,11 @@
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 451 $ # $Revision: 567 $
__author__ = "Cyril Jaquier" __author__ = "Cyril Jaquier"
__version__ = "$Revision: 451 $" __version__ = "$Revision: 567 $"
__date__ = "$Date: 2006-11-06 23:47:24 +0100 (Mon, 06 Nov 2006) $" __date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
@ -99,7 +99,7 @@ class FilterGamin(Filter):
def run(self): def run(self):
self.setActive(True) self.setActive(True)
while self.isActive(): while self._isActive():
if not self.getIdle(): if not self.getIdle():
# We cannot block here because we want to be able to # We cannot block here because we want to be able to
# exit. # exit.
@ -117,5 +117,15 @@ class FilterGamin(Filter):
time.sleep(self.getSleepTime()) time.sleep(self.getSleepTime())
else: else:
time.sleep(self.getSleepTime()) time.sleep(self.getSleepTime())
# Cleanup Gamin
self.__cleanup()
logSys.debug(self.jail.getName() + ": filter terminated") logSys.debug(self.jail.getName() + ": filter terminated")
return True 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

View File

@ -16,11 +16,11 @@
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 504 $ # $Revision: 567 $
__author__ = "Cyril Jaquier" __author__ = "Cyril Jaquier"
__version__ = "$Revision: 504 $" __version__ = "$Revision: 567 $"
__date__ = "$Date: 2006-12-23 17:37:17 +0100 (Sat, 23 Dec 2006) $" __date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
@ -93,7 +93,7 @@ class FilterPoll(Filter):
def run(self): def run(self):
self.setActive(True) self.setActive(True)
while self.isActive(): while self._isActive():
if not self.getIdle(): if not self.getIdle():
# Get file modification # Get file modification
for f in self.getLogPath(): for f in self.getLogPath():

View File

@ -16,11 +16,11 @@
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 452 $ # $Revision: 567 $
__author__ = "Cyril Jaquier" __author__ = "Cyril Jaquier"
__version__ = "$Revision: 452 $" __version__ = "$Revision: 567 $"
__date__ = "$Date: 2006-11-06 23:48:46 +0100 (Mon, 06 Nov 2006) $" __date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
@ -89,10 +89,10 @@ class Jail:
self.__filter.join() self.__filter.join()
self.__action.join() self.__action.join()
def isActive(self): def isAlive(self):
isActive0 = self.__filter.isActive() isAlive0 = self.__filter.isAlive()
isActive1 = self.__action.isActive() isAlive1 = self.__action.isAlive()
return isActive0 or isActive1 return isAlive0 or isAlive1
def setIdle(self, value): def setIdle(self, value):
self.__filter.setIdle(value) self.__filter.setIdle(value)

View File

@ -16,11 +16,11 @@
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 433 $ # $Revision: 567 $
__author__ = "Cyril Jaquier" __author__ = "Cyril Jaquier"
__version__ = "$Revision: 433 $" __version__ = "$Revision: 567 $"
__date__ = "$Date: 2006-10-24 21:40:51 +0200 (Tue, 24 Oct 2006) $" __date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
@ -105,7 +105,7 @@ class JailThread(Thread):
# Check if the filter thread is running. # Check if the filter thread is running.
# @return True if the thread is running # @return True if the thread is running
def isActive(self): def _isActive(self):
return self.__isRunning return self.__isRunning
## ##

View File

@ -16,11 +16,11 @@
# Author: Cyril Jaquier # Author: Cyril Jaquier
# #
# $Revision: 503 $ # $Revision: 567 $
__author__ = "Cyril Jaquier" __author__ = "Cyril Jaquier"
__version__ = "$Revision: 503 $" __version__ = "$Revision: 567 $"
__date__ = "$Date: 2006-12-23 17:31:00 +0100 (Sat, 23 Dec 2006) $" __date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
@ -96,7 +96,7 @@ class Server:
def startJail(self, name): def startJail(self, name):
try: try:
self.__lock.acquire() self.__lock.acquire()
if not self.isActive(name): if not self.isAlive(name):
self.__jails.get(name).start() self.__jails.get(name).start()
finally: finally:
self.__lock.release() self.__lock.release()
@ -104,7 +104,7 @@ class Server:
def stopJail(self, name): def stopJail(self, name):
try: try:
self.__lock.acquire() self.__lock.acquire()
if self.isActive(name): if self.isAlive(name):
self.__jails.get(name).stop() self.__jails.get(name).stop()
self.delJail(name) self.delJail(name)
finally: finally:
@ -118,8 +118,8 @@ class Server:
finally: finally:
self.__lock.release() self.__lock.release()
def isActive(self, name): def isAlive(self, name):
return self.__jails.get(name).isActive() return self.__jails.get(name).isAlive()
def setIdleJail(self, name, value): def setIdleJail(self, name, value):
self.__jails.get(name).setIdle(value) self.__jails.get(name).setIdle(value)
@ -326,15 +326,18 @@ class Server:
else: else:
# Target should be a file # Target should be a file
try: try:
open(target, "a") open(target, "a").close()
hdlr = logging.FileHandler(target) hdlr = logging.FileHandler(target)
except IOError: except IOError:
logSys.error("Unable to log to " + target) logSys.error("Unable to log to " + target)
logSys.info("Logging to previous target " + self.__logTarget) logSys.info("Logging to previous target " + self.__logTarget)
return False return False
self.__logTarget = target self.__logTarget = target
# Remove previous handler # Removes previous handlers
logging.getLogger("fail2ban").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 # set a format which is simpler for console use
formatter = logging.Formatter("%(asctime)s %(name)-16s: %(levelname)-6s %(message)s") formatter = logging.Formatter("%(asctime)s %(name)-16s: %(levelname)-6s %(message)s")
# tell the handler to use this format # tell the handler to use this format