diff --git a/fail2ban/client/fail2banclient.py b/fail2ban/client/fail2banclient.py index e8fa410d..941a8661 100755 --- a/fail2ban/client/fail2banclient.py +++ b/fail2ban/client/fail2banclient.py @@ -406,6 +406,8 @@ class Fail2banClient(Fail2banCmdLine, Thread): if ret is not None: if ret: return True + if self._conf.get("test", False) and not self._args: # test only + return False raise ServerExecutionException("Init of command line failed") # Commands diff --git a/fail2ban/client/fail2bancmdline.py b/fail2ban/client/fail2bancmdline.py index 62008288..49b32ddb 100644 --- a/fail2ban/client/fail2bancmdline.py +++ b/fail2ban/client/fail2bancmdline.py @@ -260,12 +260,15 @@ class Fail2banCmdLine(): if readcfg: readcfg = False ret, stream = self.readConfig() - if not ret: - raise ServerExecutionException("ERROR: test configuration failed") # exit after test if no commands specified (test only): if not len(self._args): - output("OK: configuration test is successful") + if ret: + output("OK: configuration test is successful") + else: + output("ERROR: test configuration failed") return ret + if not ret: + raise ServerExecutionException("ERROR: test configuration failed") # Nothing to do here, process in client/server return None