diff --git a/2651.patch b/2651.patch new file mode 100644 index 0000000..520d5d2 --- /dev/null +++ b/2651.patch @@ -0,0 +1,65 @@ +From 781a25512b107828aff71998c19f2fa4dbf471c1 Mon Sep 17 00:00:00 2001 +From: "Sergey G. Brester" +Date: Fri, 6 Mar 2020 19:04:39 +0100 +Subject: [PATCH 1/4] travis CI: add 3.9-dev as target + +--- + .travis.yml | 1 + + 1 file changed, 1 insertion(+) + +--- a/fail2ban/server/jailthread.py ++++ b/fail2ban/server/jailthread.py +@@ -120,3 +120,6 @@ class JailThread(Thread): + ## python 2.x replace binding of private __bootstrap method: + if sys.version_info < (3,): # pragma: 3.x no cover + JailThread._Thread__bootstrap = JailThread._JailThread__bootstrap ++## python 3.9, restore isAlive method: ++elif not hasattr(JailThread, 'isAlive'): # pragma: 2.x no cover ++ JailThread.isAlive = JailThread.is_alive +--- a/fail2ban/tests/sockettestcase.py ++++ b/fail2ban/tests/sockettestcase.py +@@ -87,7 +87,7 @@ class Socket(LogCaptureTestCase): + def _stopServerThread(self): + serverThread = self.serverThread + # wait for end of thread : +- Utils.wait_for(lambda: not serverThread.isAlive() ++ Utils.wait_for(lambda: not serverThread.is_alive() + or serverThread.join(Utils.DEFAULT_SLEEP_TIME), unittest.F2B.maxWaitTime(10)) + self.serverThread = None + +@@ -98,7 +98,7 @@ class Socket(LogCaptureTestCase): + self.server.close() + # wait for end of thread : + self._stopServerThread() +- self.assertFalse(serverThread.isAlive()) ++ self.assertFalse(serverThread.is_alive()) + # clean : + self.server.stop() + self.assertFalse(self.server.isActive()) +@@ -139,7 +139,7 @@ class Socket(LogCaptureTestCase): + self.server.stop() + # wait for end of thread : + self._stopServerThread() +- self.assertFalse(serverThread.isAlive()) ++ self.assertFalse(serverThread.is_alive()) + self.assertFalse(self.server.isActive()) + self.assertFalse(os.path.exists(self.sock_name)) + +@@ -180,7 +180,7 @@ class Socket(LogCaptureTestCase): + self.server.stop() + # wait for end of thread : + self._stopServerThread() +- self.assertFalse(serverThread.isAlive()) ++ self.assertFalse(serverThread.is_alive()) + + def testLoopErrors(self): + # replace poll handler to produce error in loop-cycle: +@@ -216,7 +216,7 @@ class Socket(LogCaptureTestCase): + self.server.stop() + # wait for end of thread : + self._stopServerThread() +- self.assertFalse(serverThread.isAlive()) ++ self.assertFalse(serverThread.is_alive()) + self.assertFalse(self.server.isActive()) + self.assertFalse(os.path.exists(self.sock_name)) + diff --git a/343ec1cdd296530f331637c725bd2bb0549e01e6.patch b/343ec1cdd296530f331637c725bd2bb0549e01e6.patch new file mode 100644 index 0000000..fb597ad --- /dev/null +++ b/343ec1cdd296530f331637c725bd2bb0549e01e6.patch @@ -0,0 +1,54 @@ +From 343ec1cdd296530f331637c725bd2bb0549e01e6 Mon Sep 17 00:00:00 2001 +From: sebres +Date: Wed, 18 Mar 2020 20:37:25 +0100 +Subject: [PATCH] test-causes: avoid host-depending issue (mistakenly ignoring + IP 127.0.0.2 as own address) - replace loop-back addr with test sub-net addr + (and disable ignoreself) + +--- + fail2ban/tests/observertestcase.py | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/fail2ban/tests/observertestcase.py b/fail2ban/tests/observertestcase.py +index 8e9444548..e379ccd18 100644 +--- a/fail2ban/tests/observertestcase.py ++++ b/fail2ban/tests/observertestcase.py +@@ -36,7 +36,6 @@ + from ..server.observer import Observers, ObserverThread + from ..server.utils import Utils + from .utils import LogCaptureTestCase +-from ..server.filter import Filter + from .dummyjail import DummyJail + + from .databasetestcase import getFail2BanDb, Fail2BanDb +@@ -224,7 +223,7 @@ def testBanTimeIncr(self): + jail.actions.setBanTime(10) + jail.setBanTimeExtra('increment', 'true') + jail.setBanTimeExtra('multipliers', '1 2 4 8 16 32 64 128 256 512 1024 2048') +- ip = "127.0.0.2" ++ ip = "192.0.2.1" + # used as start and fromtime (like now but time independence, cause test case can run slow): + stime = int(MyTime.time()) + ticket = FailTicket(ip, stime, []) +@@ -385,10 +384,12 @@ def testBanTimeIncr(self): + + # two separate jails : + jail1 = DummyJail(backend='polling') ++ jail1.filter.ignoreSelf = False + jail1.setBanTimeExtra('increment', 'true') + jail1.database = self.db + self.db.addJail(jail1) + jail2 = DummyJail(name='DummyJail-2', backend='polling') ++ jail2.filter.ignoreSelf = False + jail2.database = self.db + self.db.addJail(jail2) + ticket1 = FailTicket(ip, stime, []) +@@ -477,7 +478,7 @@ def testObserver(self): + self.assertEqual(tickets, []) + + # add failure: +- ip = "127.0.0.2" ++ ip = "192.0.2.1" + ticket = FailTicket(ip, stime-120, []) + failManager = FailManager() + failManager.setMaxRetry(3) diff --git a/8dc6f30cdd855c41b80ebdde3fe2bc91cc94e594.patch b/8dc6f30cdd855c41b80ebdde3fe2bc91cc94e594.patch index de372f3..abc806c 100644 --- a/8dc6f30cdd855c41b80ebdde3fe2bc91cc94e594.patch +++ b/8dc6f30cdd855c41b80ebdde3fe2bc91cc94e594.patch @@ -20,11 +20,9 @@ Subject: [PATCH] closes #2596: fixed supplying of backend-related `logtype` to create mode 100644 fail2ban/tests/config/filter.d/checklogtype.conf create mode 100644 fail2ban/tests/config/filter.d/checklogtype_test.conf -diff --git a/MANIFEST b/MANIFEST -index dbcc2f602..5680492af 100644 --- a/MANIFEST +++ b/MANIFEST -@@ -226,6 +226,8 @@ fail2ban/tests/clientreadertestcase.py +@@ -227,6 +227,8 @@ fail2ban/tests/clientreadertestcase.py fail2ban/tests/config/action.d/action.conf fail2ban/tests/config/action.d/brokenaction.conf fail2ban/tests/config/fail2ban.conf @@ -33,11 +31,9 @@ index dbcc2f602..5680492af 100644 fail2ban/tests/config/filter.d/simple.conf fail2ban/tests/config/filter.d/test.conf fail2ban/tests/config/filter.d/test.local -diff --git a/fail2ban/client/configreader.py b/fail2ban/client/configreader.py -index 66b987b28..20709b724 100644 --- a/fail2ban/client/configreader.py +++ b/fail2ban/client/configreader.py -@@ -120,6 +120,10 @@ def has_section(self, sec): +@@ -120,6 +120,10 @@ class ConfigReader(): except AttributeError: return False @@ -48,7 +44,7 @@ index 66b987b28..20709b724 100644 def merge_defaults(self, d): self._cfg.get_defaults().update(d) -@@ -261,8 +265,8 @@ def getOptions(self, sec, options, pOptions=None, shouldExist=False): +@@ -261,8 +265,8 @@ class ConfigReaderUnshared(SafeConfigPar logSys.warning("'%s' not defined in '%s'. Using default one: %r" % (optname, sec, optvalue)) values[optname] = optvalue @@ -59,11 +55,9 @@ index 66b987b28..20709b724 100644 except ValueError: logSys.warning("Wrong value for '" + optname + "' in '" + sec + "'. Using default one: '" + repr(optvalue) + "'") -diff --git a/fail2ban/client/fail2banregex.py b/fail2ban/client/fail2banregex.py -index f6a4b141c..334c031f4 100644 --- a/fail2ban/client/fail2banregex.py +++ b/fail2ban/client/fail2banregex.py -@@ -372,11 +372,8 @@ def readRegex(self, value, regextype): +@@ -372,11 +372,8 @@ class Fail2banRegex(object): if not ret: output( "ERROR: failed to load filter %s" % value ) return False @@ -77,11 +71,9 @@ index f6a4b141c..334c031f4 100644 # get, interpolate and convert options: reader.getOptions(None) # show real options if expected: -diff --git a/fail2ban/client/filterreader.py b/fail2ban/client/filterreader.py -index ede18dca2..413f125e6 100644 --- a/fail2ban/client/filterreader.py +++ b/fail2ban/client/filterreader.py -@@ -53,6 +53,14 @@ def setFile(self, fileName): +@@ -53,6 +53,14 @@ class FilterReader(DefinitionInitConfigR def getFile(self): return self.__file @@ -96,11 +88,9 @@ index ede18dca2..413f125e6 100644 def convert(self): stream = list() opts = self.getCombined() -diff --git a/fail2ban/client/jailreader.py b/fail2ban/client/jailreader.py -index 917a562ce..1d7db0dc9 100644 --- a/fail2ban/client/jailreader.py +++ b/fail2ban/client/jailreader.py -@@ -142,11 +142,8 @@ def getOptions(self): +@@ -149,11 +149,8 @@ class JailReader(ConfigReader): ret = self.__filter.read() if not ret: raise JailDefError("Unable to read the filter %r" % filterName) @@ -114,11 +104,9 @@ index 917a562ce..1d7db0dc9 100644 # merge options from filter as 'known/...' (all options unfiltered): self.__filter.getOptions(self.__opts, all=True) ConfigReader.merge_section(self, self.__name, self.__filter.getCombined(), 'known/') -diff --git a/fail2ban/tests/clientreadertestcase.py b/fail2ban/tests/clientreadertestcase.py -index d39860f47..2c1d0a0e4 100644 --- a/fail2ban/tests/clientreadertestcase.py +++ b/fail2ban/tests/clientreadertestcase.py -@@ -328,7 +328,22 @@ def testOverrideFilterOptInJail(self): +@@ -328,7 +328,22 @@ class JailReaderTest(LogCaptureTestCase) self.assertFalse(len(o) > 2 and o[2].endswith('regex')) i += 1 if i > usednsidx: break @@ -142,9 +130,6 @@ index d39860f47..2c1d0a0e4 100644 def testSplitOption(self): # Simple example option = "mail-whois[name=SSH]" -diff --git a/fail2ban/tests/config/filter.d/checklogtype.conf b/fail2ban/tests/config/filter.d/checklogtype.conf -new file mode 100644 -index 000000000..4d700fffa --- /dev/null +++ b/fail2ban/tests/config/filter.d/checklogtype.conf @@ -0,0 +1,31 @@ @@ -179,9 +164,6 @@ index 000000000..4d700fffa +# specified in init parameter of jail (see ../jail.conf, jail checklogtype_init): +[lt_init] +__prefix_line = INIT -diff --git a/fail2ban/tests/config/filter.d/checklogtype_test.conf b/fail2ban/tests/config/filter.d/checklogtype_test.conf -new file mode 100644 -index 000000000..a76f5fcfb --- /dev/null +++ b/fail2ban/tests/config/filter.d/checklogtype_test.conf @@ -0,0 +1,12 @@ @@ -198,8 +180,6 @@ index 000000000..a76f5fcfb +# overwrite logtype in definition (no backend anymore): +logtype = test \ No newline at end of file -diff --git a/fail2ban/tests/config/jail.conf b/fail2ban/tests/config/jail.conf -index de5bbbdc5..b1a1707b6 100644 --- a/fail2ban/tests/config/jail.conf +++ b/fail2ban/tests/config/jail.conf @@ -74,3 +74,28 @@ journalmatch = _COMM=test diff --git a/fail2ban.spec b/fail2ban.spec index 27557e1..77698e5 100644 --- a/fail2ban.spec +++ b/fail2ban.spec @@ -24,6 +24,10 @@ Patch3: https://github.com/fail2ban/fail2ban/commit/8694c547285c4030d4bf76619816 Patch4: https://github.com/fail2ban/fail2ban/commit/8dc6f30cdd855c41b80ebdde3fe2bc91cc94e594.patch # Fix test install Patch5: https://patch-diff.githubusercontent.com/raw/fail2ban/fail2ban/pull/2605.patch +# Patch for Python 3.9 +# https://bugzilla.redhat.com/show_bug.cgi?id=1808347 +Patch6: https://patch-diff.githubusercontent.com/raw/fail2ban/fail2ban/pull/2651.patch +Patch7: https://github.com/fail2ban/fail2ban/commit/343ec1cdd296530f331637c725bd2bb0549e01e6.patch BuildRequires: python3-devel BuildRequires: /usr/bin/2to3