mirror of https://github.com/fail2ban/fail2ban
Merge branch '0.10' into 0.11
commit
5ddab17089
|
@ -787,7 +787,10 @@ class CommandAction(ActionBase):
|
||||||
# otherwise stop/start will theoretically remove all the bans,
|
# otherwise stop/start will theoretically remove all the bans,
|
||||||
# but the tickets are still in BanManager, so in case of new failures
|
# but the tickets are still in BanManager, so in case of new failures
|
||||||
# it will not be banned, because "already banned" will happen.
|
# it will not be banned, because "already banned" will happen.
|
||||||
self.stop()
|
try:
|
||||||
|
self.stop()
|
||||||
|
except RuntimeError: # bypass error in stop (if start/check succeeded hereafter).
|
||||||
|
pass
|
||||||
self.start()
|
self.start()
|
||||||
if not self.executeCmd(checkCmd, self.timeout):
|
if not self.executeCmd(checkCmd, self.timeout):
|
||||||
self._logSys.critical("Unable to restore environment")
|
self._logSys.critical("Unable to restore environment")
|
||||||
|
|
|
@ -335,7 +335,16 @@ class CommandActionTest(LogCaptureTestCase):
|
||||||
self.__action.actionban = "rm /tmp/fail2ban.test"
|
self.__action.actionban = "rm /tmp/fail2ban.test"
|
||||||
self.__action.actioncheck = "[ -e /tmp/fail2ban.test ]"
|
self.__action.actioncheck = "[ -e /tmp/fail2ban.test ]"
|
||||||
self.assertRaises(RuntimeError, self.__action.ban, {'ip': None})
|
self.assertRaises(RuntimeError, self.__action.ban, {'ip': None})
|
||||||
self.assertLogged('Unable to restore environment')
|
self.assertLogged('Invariant check failed', 'Unable to restore environment', all=True)
|
||||||
|
# 2nd time, try to restore with producing error in stop, but succeeded start hereafter:
|
||||||
|
self.pruneLog('[phase 2]')
|
||||||
|
self.__action.actionstart = "touch /tmp/fail2ban.test"
|
||||||
|
self.__action.actionstop = "rm /tmp/fail2ban.test"
|
||||||
|
self.__action.actionban = 'printf "%%b\n" <ip> >> /tmp/fail2ban.test'
|
||||||
|
self.__action.actioncheck = "[ -e /tmp/fail2ban.test ]"
|
||||||
|
self.__action.ban({'ip': None})
|
||||||
|
self.assertLogged('Invariant check failed')
|
||||||
|
self.assertNotLogged('Unable to restore environment')
|
||||||
|
|
||||||
def testExecuteActionCheckRepairEnvironment(self):
|
def testExecuteActionCheckRepairEnvironment(self):
|
||||||
self.__action.actionstart = ""
|
self.__action.actionstart = ""
|
||||||
|
|
Loading…
Reference in New Issue