mirror of https://github.com/fail2ban/fail2ban
- Removed log4py dependency
- Better handling of the return value of os.system() git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@163 a942ae1a-1317-0410-a47c-b1dcaea8d6050.5
parent
4d9c24adbf
commit
8688acab65
|
@ -24,10 +24,10 @@ __date__ = "$Date$"
|
||||||
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
||||||
__license__ = "GPL"
|
__license__ = "GPL"
|
||||||
|
|
||||||
import os, log4py, signal
|
import os, logging, signal
|
||||||
|
|
||||||
# Gets the instance of log4py.
|
# Gets the instance of the logger.
|
||||||
logSys = log4py.Logger().get_instance()
|
logSys = logging.getLogger("fail2ban")
|
||||||
|
|
||||||
def createDaemon():
|
def createDaemon():
|
||||||
"""Detach a process from the controlling terminal and run it in the
|
"""Detach a process from the controlling terminal and run it in the
|
||||||
|
@ -111,6 +111,7 @@ def checkForPID(lockfile):
|
||||||
try:
|
try:
|
||||||
fileHandler = open(lockfile)
|
fileHandler = open(lockfile)
|
||||||
pid = fileHandler.readline()
|
pid = fileHandler.readline()
|
||||||
|
fileHandler.close()
|
||||||
return pid
|
return pid
|
||||||
except IOError:
|
except IOError:
|
||||||
return False
|
return False
|
||||||
|
@ -151,6 +152,9 @@ def executeCmd(cmd, debug):
|
||||||
|
|
||||||
logSys.debug(cmd)
|
logSys.debug(cmd)
|
||||||
if not debug:
|
if not debug:
|
||||||
return os.system(cmd)
|
retval = os.system(cmd)
|
||||||
|
if not retval == 0:
|
||||||
|
logSys.error("'" + cmd + "' returned " + `retval`)
|
||||||
|
return retval
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue