|
|
|
@ -46,11 +46,11 @@ class Server:
|
|
|
|
|
self.__daemon = daemon
|
|
|
|
|
self.__transm = Transmitter(self)
|
|
|
|
|
self.__asyncServer = AsyncServer(self.__transm)
|
|
|
|
|
self.__logLevel = 3
|
|
|
|
|
self.__logTarget = "STDOUT"
|
|
|
|
|
self.__logLevel = None
|
|
|
|
|
self.__logTarget = None
|
|
|
|
|
# Set logging level
|
|
|
|
|
self.setLogLevel(self.__logLevel)
|
|
|
|
|
self.setLogTarget(self.__logTarget)
|
|
|
|
|
self.setLogLevel(3)
|
|
|
|
|
self.setLogTarget("STDOUT")
|
|
|
|
|
|
|
|
|
|
def __sigTERMhandler(self, signum, frame):
|
|
|
|
|
logSys.debug("Caught signal %d. Exiting" % signum)
|
|
|
|
@ -66,6 +66,7 @@ class Server:
|
|
|
|
|
# First set the mask to only allow access to owner
|
|
|
|
|
os.umask(0077)
|
|
|
|
|
if self.__daemon:
|
|
|
|
|
logSys.info("Starting in daemon mode")
|
|
|
|
|
ret = self.__createDaemon()
|
|
|
|
|
if ret:
|
|
|
|
|
logSys.info("Daemon started")
|
|
|
|
@ -346,7 +347,6 @@ class Server:
|
|
|
|
|
logSys.error("Unable to log to " + target)
|
|
|
|
|
logSys.info("Logging to previous target " + self.__logTarget)
|
|
|
|
|
return False
|
|
|
|
|
self.__logTarget = target
|
|
|
|
|
# Removes previous handlers
|
|
|
|
|
for handler in logging.getLogger("fail2ban").handlers:
|
|
|
|
|
# Closes the handler.
|
|
|
|
@ -355,6 +355,12 @@ class Server:
|
|
|
|
|
# tell the handler to use this format
|
|
|
|
|
hdlr.setFormatter(formatter)
|
|
|
|
|
logging.getLogger("fail2ban").addHandler(hdlr)
|
|
|
|
|
# Does not display this message at startup.
|
|
|
|
|
if not self.__logTarget == None:
|
|
|
|
|
logSys.info("Changed logging target to %s for Fail2ban v%s" %
|
|
|
|
|
(target, version.version))
|
|
|
|
|
# Sets the logging target.
|
|
|
|
|
self.__logTarget = target
|
|
|
|
|
return True
|
|
|
|
|
finally:
|
|
|
|
|
self.__loggingLock.release()
|
|
|
|
|