fix #1 for Cyrils adjustments

debian-releases/etch
Yaroslav Halchenko 2005-10-14 15:51:04 +00:00
parent 91df9c7526
commit f3da148d0f
2 changed files with 15 additions and 26 deletions

View File

@ -112,17 +112,16 @@ def restoreFwRules():
""" Flush the ban list
"""
logSys.warn("Restoring firewall rules...")
for element in logFwList:
try:
try:
for element in logFwList:
# Execute end command of each section
element[2].flushBanList(conf["debug"])
except ExternalError:
# nothing bad really - we can survive :-)
pass
# Execute end command of each section
for element in logFwList:
element[2].restore(conf["debug"])
# Execute global end command
executeCmd(conf["cmdend"], conf["debug"])
element[2].restore(conf["debug"])
# Execute global end command
executeCmd(conf["cmdend"], conf["debug"])
except ExternalError:
# nothing bad really - we can survive :-)
pass
def killApp():
""" Flush the ban list, remove the PID lock file and exit
@ -393,7 +392,8 @@ def main():
lObj = LogReader(l["logfile"], l["timeregex"], l["timepattern"],
l["failregex"], l["maxfailures"], l["findtime"])
# Creates a firewall object
fObj = Firewall(l["fwban"], l["fwunban"], l["fwcheck"], l["bantime"])
fObj = Firewall(l["fwstart"], l["fwend"],
l["fwban"], l["fwunban"], l["fwcheck"], l["bantime"])
# Links them into a list. I'm not really happy
# with this :/
logFwList.append([t, lObj, fObj, dict()])

View File

@ -37,27 +37,16 @@ class Firewall:
the IP.
"""
def __init__(self, banRule, unBanRule, checkRule, banTime):
def __init__(self, startRule, endRule,
banRule, unBanRule, checkRule, banTime):
self.banRule = banRule
self.unBanRule = unBanRule
self.checkRule = checkRule
self.startRule = ""
self.endRule = ""
self.startRule = startRule
self.endRule = endRule
self.banTime = banTime
self.banList = dict()
def setStartRule(self, cmd):
self.startRule = cmd
def getStartRule(self):
return self.startRule
def setEndRule(self, cmd):
self.endRule = cmd
def getEndRule(self):
return self.endRule
def initialize(self, debug):
logSys.debug("Initialize firewall rules")
executeCmd(self.startRule, debug)