- Splitted "checkForPID" into "createPID" and "checkForPID". Fixed the bug which created a PID lock file when calling Fail2Ban with the kill option

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@71 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.6
Cyril Jaquier 20 years ago
parent c429a69845
commit 3d9318ad3e

@ -175,13 +175,17 @@ def checkForPID(lockfile):
pid = fileHandler.readline()
return pid
except IOError:
fileHandler = open(lockfile, mode='w')
pid = os.getpid()
fileHandler.write(`pid`+'\n')
fileHandler.close()
logSys.debug("Created PID lock ("+`pid`+") in "+lockfile)
return False
def createPID(lockfile):
""" Creates a PID lock file with the current PID.
"""
fileHandler = open(lockfile, mode='w')
pid = os.getpid()
fileHandler.write(`pid`+'\n')
fileHandler.close()
logSys.debug("Created PID lock ("+`pid`+") in "+lockfile)
def removePID(lockfile):
""" Remove PID lock.
"""
@ -424,6 +428,8 @@ if __name__ == "__main__":
if pid:
logSys.error("Fail2Ban already running with PID "+pid)
sys.exit(-1)
else:
createPID(conf["pidlock"])
logSys.debug("ConfFile is "+conf["conffile"])
logSys.debug("BanTime is "+`conf["bantime"]`)

Loading…
Cancel
Save