mirror of https://github.com/fail2ban/fail2ban
- fail2ban-client returns an error code if configuration is not valid
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@518 a942ae1a-1317-0410-a47c-b1dcaea8d6050.x
parent
ffc9c5d8f9
commit
2725dd6f22
|
@ -11,6 +11,8 @@ ver. 0.7.7 (2007/??/??)
|
||||||
----------
|
----------
|
||||||
- Added signal handling in fail2ban-client
|
- Added signal handling in fail2ban-client
|
||||||
- Added a wonderful visual effect when waiting on the server
|
- Added a wonderful visual effect when waiting on the server
|
||||||
|
- fail2ban-client returns an error code if configuration is
|
||||||
|
not valid
|
||||||
|
|
||||||
ver. 0.7.6 (2007/01/04) - beta
|
ver. 0.7.6 (2007/01/04) - beta
|
||||||
----------
|
----------
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Configurator:
|
||||||
|
|
||||||
def getAllOptions(self):
|
def getAllOptions(self):
|
||||||
self.__fail2ban.getOptions()
|
self.__fail2ban.getOptions()
|
||||||
self.__jails.getOptions()
|
return self.__jails.getOptions()
|
||||||
|
|
||||||
def convertToProtocol(self):
|
def convertToProtocol(self):
|
||||||
self.__streams["general"] = self.__fail2ban.convert()
|
self.__streams["general"] = self.__fail2ban.convert()
|
||||||
|
|
|
@ -54,6 +54,8 @@ class JailsReader(ConfigReader):
|
||||||
self.__jails.append(jail)
|
self.__jails.append(jail)
|
||||||
else:
|
else:
|
||||||
logSys.error("Errors in jail '" + sec + "'. Skipping...")
|
logSys.error("Errors in jail '" + sec + "'. Skipping...")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def convert(self):
|
def convert(self):
|
||||||
stream = list()
|
stream = list()
|
||||||
|
|
|
@ -175,10 +175,14 @@ class Fail2banClient:
|
||||||
logSys.error("Server already running")
|
logSys.error("Server already running")
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
# Read the config
|
||||||
|
ret = self.__readConfig()
|
||||||
|
# Do not continue if configuration is not 100% valid
|
||||||
|
if not ret:
|
||||||
|
return False
|
||||||
|
# Start the server
|
||||||
self.__startServerAsync(self.__conf["socket"],
|
self.__startServerAsync(self.__conf["socket"],
|
||||||
self.__conf["force"])
|
self.__conf["force"])
|
||||||
# Read the config while the server is starting
|
|
||||||
self.__readConfig()
|
|
||||||
try:
|
try:
|
||||||
# Wait for the server to start
|
# Wait for the server to start
|
||||||
self.__waitOnServer()
|
self.__waitOnServer()
|
||||||
|
@ -194,7 +198,10 @@ class Fail2banClient:
|
||||||
return False
|
return False
|
||||||
elif len(cmd) == 1 and cmd[0] == "reload":
|
elif len(cmd) == 1 and cmd[0] == "reload":
|
||||||
if self.__ping():
|
if self.__ping():
|
||||||
self.__readConfig()
|
ret = self.__readConfig()
|
||||||
|
# Do not continue if configuration is not 100% valid
|
||||||
|
if not ret:
|
||||||
|
return False
|
||||||
self.__processCmd([['stop', 'all']], False)
|
self.__processCmd([['stop', 'all']], False)
|
||||||
# Configure the server
|
# Configure the server
|
||||||
return self.__processCmd(self.__stream, False)
|
return self.__processCmd(self.__stream, False)
|
||||||
|
@ -312,9 +319,9 @@ class Fail2banClient:
|
||||||
logSys.info("Using socket file " + self.__conf["socket"])
|
logSys.info("Using socket file " + self.__conf["socket"])
|
||||||
|
|
||||||
if self.__conf["dump"]:
|
if self.__conf["dump"]:
|
||||||
self.__readConfig()
|
ret = self.__readConfig()
|
||||||
self.dumpConfig(self.__stream)
|
self.dumpConfig(self.__stream)
|
||||||
return True
|
return ret
|
||||||
|
|
||||||
# Interactive mode
|
# Interactive mode
|
||||||
if self.__conf["interactive"]:
|
if self.__conf["interactive"]:
|
||||||
|
@ -345,9 +352,10 @@ class Fail2banClient:
|
||||||
def __readConfig(self):
|
def __readConfig(self):
|
||||||
# Read the configuration
|
# Read the configuration
|
||||||
self.__configurator.readAll()
|
self.__configurator.readAll()
|
||||||
self.__configurator.getAllOptions()
|
ret = self.__configurator.getAllOptions()
|
||||||
self.__configurator.convertToProtocol()
|
self.__configurator.convertToProtocol()
|
||||||
self.__stream = self.__configurator.getConfigStream()
|
self.__stream = self.__configurator.getConfigStream()
|
||||||
|
return ret
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def dumpConfig(cmd):
|
def dumpConfig(cmd):
|
||||||
|
|
Loading…
Reference in New Issue