mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
- Added a more robust firewall initialization loop. Thanks to Yaroslav Halchenko
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@235 a942ae1a-1317-0410-a47c-b1dcaea8d605
This commit is contained in:
parent
627539dd1c
commit
e57f6ad474
1 changed files with 19 additions and 1 deletions
20
fail2ban.py
20
fail2ban.py
|
|
@ -423,7 +423,25 @@ def main():
|
|||
else:
|
||||
logSys.warn(ip + " is not a valid IP address")
|
||||
|
||||
initializeFwRules()
|
||||
# Startup loop -- necessary to avoid crash if it takes time for iptables
|
||||
# to startup. To avoid introduction of new config options, reusing
|
||||
# maxreinits and polltime.
|
||||
reinits = 0
|
||||
while True:
|
||||
try:
|
||||
initializeFwRules()
|
||||
break
|
||||
except ExternalError, e:
|
||||
reinits += 1
|
||||
logSys.warn(e)
|
||||
if conf["maxreinits"] < 0 or (reinits < conf["maxreinits"]):
|
||||
logSys.warn("#%d attempt to initialize the firewalls" % reinits)
|
||||
else:
|
||||
logSys.error("Exiting: Too many attempts to initialize the " +
|
||||
"firewall")
|
||||
killApp()
|
||||
time.sleep(conf["polltime"])
|
||||
|
||||
# try to reinit once if it fails immediately
|
||||
lastReinitTime = time.time() - conf["reinittime"] - 1
|
||||
reinits = 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue