mirror of https://github.com/fail2ban/fail2ban
- Fixed a bug with "-k"
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@177 a942ae1a-1317-0410-a47c-b1dcaea8d6050.5
parent
9548edaff0
commit
d2f3d1c263
29
fail2ban.py
29
fail2ban.py
|
@ -137,14 +137,7 @@ def getCmdLineOptions(optList):
|
||||||
if opt[0] == "-p":
|
if opt[0] == "-p":
|
||||||
conf["pidlock"] = opt[1]
|
conf["pidlock"] = opt[1]
|
||||||
if opt[0] == "-k":
|
if opt[0] == "-k":
|
||||||
pid = checkForPID(conf["pidlock"])
|
conf["kill"] = True
|
||||||
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)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" Fail2Ban main function
|
""" Fail2Ban main function
|
||||||
|
@ -197,6 +190,23 @@ def main():
|
||||||
# Gets command line options
|
# Gets command line options
|
||||||
getCmdLineOptions(optList)
|
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
|
# Start Fail2Ban in daemon mode
|
||||||
if conf["background"]:
|
if conf["background"]:
|
||||||
retCode = createDaemon()
|
retCode = createDaemon()
|
||||||
|
@ -244,9 +254,6 @@ def main():
|
||||||
hdlr.setFormatter(formatter)
|
hdlr.setFormatter(formatter)
|
||||||
logSys.addHandler(hdlr)
|
logSys.addHandler(hdlr)
|
||||||
|
|
||||||
# PID lock
|
|
||||||
pidLock.setPath(conf["pidlock"])
|
|
||||||
|
|
||||||
# Ignores IP list
|
# Ignores IP list
|
||||||
ignoreIPList = conf["ignoreip"].split(' ')
|
ignoreIPList = conf["ignoreip"].split(' ')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue