mirror of https://github.com/fail2ban/fail2ban
- Added "ExternalError" exception
- Raise "ExternalError" exception in "executeCmd()" if "system()" fails git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@207 a942ae1a-1317-0410-a47c-b1dcaea8d6050.5
parent
5556c78350
commit
1d09db666d
|
@ -29,6 +29,11 @@ import os, logging, signal
|
||||||
# Gets the instance of the logger.
|
# Gets the instance of the logger.
|
||||||
logSys = logging.getLogger("fail2ban")
|
logSys = logging.getLogger("fail2ban")
|
||||||
|
|
||||||
|
class ExternalError(UserWarning):
|
||||||
|
""" Exception to warn about failed fwcheck or fwban command
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
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
|
||||||
background as a daemon.
|
background as a daemon.
|
||||||
|
@ -126,6 +131,7 @@ def executeCmd(cmd, debug):
|
||||||
retval = os.system(cmd)
|
retval = os.system(cmd)
|
||||||
if not retval == 0:
|
if not retval == 0:
|
||||||
logSys.error("'" + cmd + "' returned " + `retval`)
|
logSys.error("'" + cmd + "' returned " + `retval`)
|
||||||
|
raise ExternalError("Execution of command '%s' failed" % cmd)
|
||||||
return retval
|
return retval
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue