- Fixed a bug with "-k"

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@177 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.5
Cyril Jaquier 20 years ago
parent 9548edaff0
commit d2f3d1c263

@ -137,14 +137,7 @@ def getCmdLineOptions(optList):
if opt[0] == "-p":
conf["pidlock"] = opt[1]
if opt[0] == "-k":
pid = checkForPID(conf["pidlock"])
if pid:
killPID(int(pid))
logSys.warn("Killed Fail2Ban with PID "+pid)
sys.exit(0)
else:
logSys.error("No running Fail2Ban found")
sys.exit(-1)
conf["kill"] = True
def main():
""" Fail2Ban main function
@ -196,6 +189,23 @@ def main():
# Gets command line options
getCmdLineOptions(optList)
# PID lock
pidLock.setPath(conf["pidlock"])
# Now we can kill properly a running instance if needed
try:
conf["kill"]
pid = pidLock.exists()
if pid:
killPID(int(pid))
logSys.warn("Killed Fail2Ban with PID "+pid)
sys.exit(0)
else:
logSys.error("No running Fail2Ban found")
sys.exit(-1)
except KeyError:
pass
# Start Fail2Ban in daemon mode
if conf["background"]:
@ -244,9 +254,6 @@ def main():
hdlr.setFormatter(formatter)
logSys.addHandler(hdlr)
# PID lock
pidLock.setPath(conf["pidlock"])
# Ignores IP list
ignoreIPList = conf["ignoreip"].split(' ')

Loading…
Cancel
Save