fixed issue with crashing on wrong log file

added a cleanup of firewall on emergency exit
debian-releases/etch debian/0.5.4-5.14
Yaroslav Halchenko 2005-10-16 15:07:47 +00:00
parent e9792f95f6
commit 51d453a3d2
3 changed files with 19 additions and 7 deletions

6
debian/changelog vendored
View File

@ -1,4 +1,4 @@
fail2ban (0.5.4-5.13) unstable; urgency=low fail2ban (0.5.4-5.14) unstable; urgency=low
* Added a notification regarding the importance of 0.5.4-5 change of * Added a notification regarding the importance of 0.5.4-5 change of
failregex in the config file. failregex in the config file.
@ -20,6 +20,10 @@ fail2ban (0.5.4-5.13) unstable; urgency=low
within sections. within sections.
* Added -e command line parameter to provide enabled sections from command * Added -e command line parameter to provide enabled sections from command
line. line.
* Added a cleanup of firewall rules on emergency shutdown when unknown
exception is catched.
* Fail2ban should not crash now if a wrong file name is specified in
config.
-- Yaroslav Halchenko <debian@onerussian.com> Mon, 3 Oct 2005 22:26:28 -1000 -- Yaroslav Halchenko <debian@onerussian.com> Mon, 3 Oct 2005 22:26:28 -1000

View File

@ -55,6 +55,12 @@ except Exception, e:
logSys.error("Type: " + `type.__name__` + "\n" + logSys.error("Type: " + `type.__name__` + "\n" +
"Value: " + `e.args` + "\n" + "Value: " + `e.args` + "\n" +
"TB: " + `tbStack`) "TB: " + `tbStack`)
# Try to clean up after ourselves
# just for extreme caution - wrapping with try
try:
fail2ban.restoreFwRules()
except Exception:
pass
# Remove the PID lock file. Should close #1239562 # Remove the PID lock file. Should close #1239562
pidLock.remove() pidLock.remove()
logging.shutdown() logging.shutdown()

View File

@ -97,8 +97,6 @@ class LogReader:
""" """
try: try:
self.logStats = os.stat(self.logPath) self.logStats = os.stat(self.logPath)
except OSError:
logSys.error("Unable to get stat on "+self.logPath)
if self.lastModTime == self.logStats.st_mtime: if self.lastModTime == self.logStats.st_mtime:
return False return False
@ -106,6 +104,10 @@ class LogReader:
logSys.debug(self.logPath+" has been modified") logSys.debug(self.logPath+" has been modified")
self.lastModTime = self.logStats.st_mtime self.lastModTime = self.logStats.st_mtime
return True return True
except OSError:
logSys.error("Unable to get stat on "+self.logPath)
return False
def setFilePos(self, file): def setFilePos(self, file):
""" Sets the file position. We must take care of log file rotation """ Sets the file position. We must take care of log file rotation