From 0d9cc4aed202c9126966f7a9e73eaa7f48d51b6b Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 24 Nov 2023 15:21:26 +0800 Subject: [PATCH] fail2ban: Fix compatibility with Python 3.11 This backports 2 commits from upstream[1]; the other 3 are not strictly necessary. One of the patches has been updated to remove a change to a regex that does not exist in 0.11.2. [1]: https://github.com/fail2ban/fail2ban/pull/3267 Fixes: https://github.com/openwrt/packages/issues/22736 Signed-off-by: Jeffery To --- net/fail2ban/Makefile | 2 +- ...art-of-expression-python-3.11-compat.patch | 44 +++++++++++++++++++ ...d-by-RE-engine-in-the-python-version.patch | 36 +++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 net/fail2ban/patches/101-move-global-groups-to-start-of-expression-python-3.11-compat.patch create mode 100644 net/fail2ban/patches/102-wrap-global-flags-to-local-flags-if-supported-by-RE-engine-in-the-python-version.patch diff --git a/net/fail2ban/Makefile b/net/fail2ban/Makefile index 77568e9083..fba0a11df2 100644 --- a/net/fail2ban/Makefile +++ b/net/fail2ban/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fail2ban PKG_VERSION:=0.11.2 -PKG_RELEASE:=8 +PKG_RELEASE:=9 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/fail2ban/fail2ban/tar.gz/$(PKG_VERSION)? diff --git a/net/fail2ban/patches/101-move-global-groups-to-start-of-expression-python-3.11-compat.patch b/net/fail2ban/patches/101-move-global-groups-to-start-of-expression-python-3.11-compat.patch new file mode 100644 index 0000000000..bd50c17bba --- /dev/null +++ b/net/fail2ban/patches/101-move-global-groups-to-start-of-expression-python-3.11-compat.patch @@ -0,0 +1,44 @@ +From 7e2ab36d86998575853150c0a57de5e22518cf66 Mon Sep 17 00:00:00 2001 +From: sebres +Date: Tue, 21 Jun 2022 16:55:57 +0200 +Subject: [PATCH] move global groups to start of expression (python 3.11 + compat) + +[remove change to regex not in 0.11.2] +Signed-off-by: Jeffery To +--- + fail2ban/client/fail2banregex.py | 2 +- + fail2ban/server/datetemplate.py | 8 ++++++++ + 2 files changed, 9 insertions(+), 1 deletion(-) + +--- a/fail2ban/server/datetemplate.py ++++ b/fail2ban/server/datetemplate.py +@@ -35,6 +35,7 @@ logSys = getLogger(__name__) + # check already grouped contains "(", but ignores char "\(" and conditional "(?(id)...)": + RE_GROUPED = re.compile(r'(? +Date: Tue, 21 Jun 2022 16:56:57 +0200 +Subject: [PATCH] wrap global flags like ((?i)xxx) or (?:(?i)xxx) to local + flags (?i:xxx) if supported by RE-engine in the python version + +--- + fail2ban/server/failregex.py | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/fail2ban/server/failregex.py ++++ b/fail2ban/server/failregex.py +@@ -91,6 +91,13 @@ R_MAP = { + "port": "fport", + } + ++# map global flags like ((?i)xxx) or (?:(?i)xxx) to local flags (?i:xxx) if supported by RE-engine in this python version: ++try: ++ re.search("^re(?i:val)$", "reVAL") ++ R_GLOB2LOCFLAGS = ( re.compile(r"(?