From: <los...@us...> - 2007-01-08 21:15:48
|
Revision: 518 http://svn.sourceforge.net/fail2ban/?rev=518&view=rev Author: lostcontrol Date: 2007-01-08 13:15:47 -0800 (Mon, 08 Jan 2007) Log Message: ----------- - fail2ban-client returns an error code if configuration is not valid Modified Paths: -------------- trunk/CHANGELOG trunk/client/configurator.py trunk/client/jailsreader.py trunk/fail2ban-client Modified: trunk/CHANGELOG =================================================================== --- trunk/CHANGELOG 2007-01-08 21:09:50 UTC (rev 517) +++ trunk/CHANGELOG 2007-01-08 21:15:47 UTC (rev 518) @@ -11,6 +11,8 @@ ---------- - 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 ---------- Modified: trunk/client/configurator.py =================================================================== --- trunk/client/configurator.py 2007-01-08 21:09:50 UTC (rev 517) +++ trunk/client/configurator.py 2007-01-08 21:15:47 UTC (rev 518) @@ -60,7 +60,7 @@ def getAllOptions(self): self.__fail2ban.getOptions() - self.__jails.getOptions() + return self.__jails.getOptions() def convertToProtocol(self): self.__streams["general"] = self.__fail2ban.convert() Modified: trunk/client/jailsreader.py =================================================================== --- trunk/client/jailsreader.py 2007-01-08 21:09:50 UTC (rev 517) +++ trunk/client/jailsreader.py 2007-01-08 21:15:47 UTC (rev 518) @@ -54,6 +54,8 @@ self.__jails.append(jail) else: logSys.error("Errors in jail '" + sec + "'. Skipping...") + return False + return True def convert(self): stream = list() Modified: trunk/fail2ban-client =================================================================== --- trunk/fail2ban-client 2007-01-08 21:09:50 UTC (rev 517) +++ trunk/fail2ban-client 2007-01-08 21:15:47 UTC (rev 518) @@ -175,10 +175,14 @@ 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 @@ 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 @@ 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 @@ 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): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |