From 39d9133baa6fa389b0ab4ce2a84a8f7bb86ccb9c Mon Sep 17 00:00:00 2001 From: sebres Date: Mon, 29 Jul 2019 14:13:30 +0200 Subject: [PATCH] amend to 7520d250b0dd6afa04070ddd8c6a6c8a2b15428f (#2444): don't use default flags (SYSTEM) if journalfiles are specified (similar journalflags set to 0); fix failure of testJournalFilesArg and cover both cases now. --- fail2ban/server/filtersystemd.py | 4 +++- fail2ban/tests/filtertestcase.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fail2ban/server/filtersystemd.py b/fail2ban/server/filtersystemd.py index be5a6dc4..c2a72598 100644 --- a/fail2ban/server/filtersystemd.py +++ b/fail2ban/server/filtersystemd.py @@ -91,7 +91,9 @@ class FilterSystemd(JournalFilter): # pragma: systemd no cover try: args['flags'] = int(kwargs.pop('journalflags')) except KeyError: - args['flags'] = 4 + # be sure all journal types will be opened if files specified (don't set flags): + if 'files' not in args or not len(args['files']): + args['flags'] = 4 return args diff --git a/fail2ban/tests/filtertestcase.py b/fail2ban/tests/filtertestcase.py index b8e0e04a..46a0d0b5 100644 --- a/fail2ban/tests/filtertestcase.py +++ b/fail2ban/tests/filtertestcase.py @@ -1280,6 +1280,11 @@ def get_monitor_failures_journal_testcase(Filter_): # pragma: systemd no cover jrnlfile = self._getRuntimeJournal() self._initFilter(journalfiles=jrnlfile) + def testJournalFilesAndFlagsArgs(self): + # retrieve current system journal path + jrnlfile = self._getRuntimeJournal() + self._initFilter(journalfiles=jrnlfile, journalflags=0) + def testJournalPathArg(self): # retrieve current system journal path jrnlpath = self._getRuntimeJournal()