diff --git a/fail2ban.py b/fail2ban.py index 2dd83f92..3c4a611f 100755 --- a/fail2ban.py +++ b/fail2ban.py @@ -112,11 +112,16 @@ def restoreFwRules(): """ Flush the ban list """ logSys.warn("Restoring firewall rules...") - try: - for element in logFwList: - # Execute end command of each section - element[2].flushBanList(conf["debug"]) + for element in logFwList: + # Execute end command of each section + try: element[2].restore(conf["debug"]) + except ExternalError: + # nothing bad really - we can survive :-) + # but it has to be a separate exception handler + # for each section, so we don't miss anything + pass + try: # Execute global end command executeCmd(conf["cmdend"], conf["debug"]) except ExternalError: diff --git a/firewall/firewall.py b/firewall/firewall.py index 84f070d7..2b50fbe7 100644 --- a/firewall/firewall.py +++ b/firewall/firewall.py @@ -53,6 +53,7 @@ class Firewall: def restore(self, debug): logSys.debug("Restore firewall rules") + flushBanList(debug) executeCmd(self.endRule, debug) def addBanIP(self, aInfo, debug):