- 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-b1dcaea8d605
0.x
Cyril Jaquier 18 years ago
parent ffc9c5d8f9
commit 2725dd6f22

@ -11,6 +11,8 @@ ver. 0.7.7 (2007/??/??)
----------
- Added signal handling in fail2ban-client
- 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
----------

@ -60,7 +60,7 @@ class Configurator:
def getAllOptions(self):
self.__fail2ban.getOptions()
self.__jails.getOptions()
return self.__jails.getOptions()
def convertToProtocol(self):
self.__streams["general"] = self.__fail2ban.convert()

@ -54,6 +54,8 @@ class JailsReader(ConfigReader):
self.__jails.append(jail)
else:
logSys.error("Errors in jail '" + sec + "'. Skipping...")
return False
return True
def convert(self):
stream = list()

@ -175,10 +175,14 @@ class Fail2banClient:
logSys.error("Server already running")
return False
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.__conf["force"])
# Read the config while the server is starting
self.__readConfig()
try:
# Wait for the server to start
self.__waitOnServer()
@ -194,7 +198,10 @@ class Fail2banClient:
return False
elif len(cmd) == 1 and cmd[0] == "reload":
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)
# Configure the server
return self.__processCmd(self.__stream, False)
@ -312,9 +319,9 @@ class Fail2banClient:
logSys.info("Using socket file " + self.__conf["socket"])
if self.__conf["dump"]:
self.__readConfig()
ret = self.__readConfig()
self.dumpConfig(self.__stream)
return True
return ret
# Interactive mode
if self.__conf["interactive"]:
@ -345,9 +352,10 @@ class Fail2banClient:
def __readConfig(self):
# Read the configuration
self.__configurator.readAll()
self.__configurator.getAllOptions()
ret = self.__configurator.getAllOptions()
self.__configurator.convertToProtocol()
self.__stream = self.__configurator.getConfigStream()
return ret
@staticmethod
def dumpConfig(cmd):

Loading…
Cancel
Save