From edc2918176c622e7ff65ab9ed8e4fbf7f3be39b5 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 10 Mar 2022 23:16:02 +0100 Subject: [PATCH] * Fix a potential race condition (Closes: #935778) * Cherry-pick upstream fix for courier-auth (Closes: #1004466) --- debian/changelog | 2 ++ debian/patches/courier-auth.diff | 23 +++++++++++++++++++++++ debian/patches/fix-race.diff | 9 +++++++++ debian/patches/series | 2 ++ 4 files changed, 36 insertions(+) create mode 100644 debian/patches/courier-auth.diff create mode 100644 debian/patches/fix-race.diff diff --git a/debian/changelog b/debian/changelog index f24d76c3..4093a2b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ fail2ban (0.11.2-6) unstable; urgency=medium * Cherry-pick upstream fix to fix a startup issue with Python 3.10 (LP: #1958505) + * Fix a potential race condition (Closes: #935778) + * Cherry-pick upstream fix for courier-auth (Closes: #1004466) -- Sylvestre Ledru Thu, 10 Mar 2022 22:52:59 +0100 diff --git a/debian/patches/courier-auth.diff b/debian/patches/courier-auth.diff new file mode 100644 index 00000000..68df4c65 --- /dev/null +++ b/debian/patches/courier-auth.diff @@ -0,0 +1,23 @@ +diff --git a/config/filter.d/courier-auth.conf b/config/filter.d/courier-auth.conf +index 1ac33736a..d5ba9c505 100644 +--- a/config/filter.d/courier-auth.conf ++++ b/config/filter.d/courier-auth.conf +@@ -11,7 +11,7 @@ before = common.conf + + _daemon = (?:courier)?(?:imapd?|pop3d?)(?:login)?(?:-ssl)? + +-failregex = ^%(__prefix_line)sLOGIN FAILED, (?:user|method)=.*, ip=\[\]$ ++failregex = ^%(__prefix_line)sLOGIN FAILED, (?:(?!ip=)(?:user=[^,]*|\w+=[^,]*), )*ip=\[\] + + ignoreregex = + +diff --git a/fail2ban/tests/files/logs/courier-auth b/fail2ban/tests/files/logs/courier-auth +index 3505e1092..8a20a27fb 100644 +--- a/fail2ban/tests/files/logs/courier-auth ++++ b/fail2ban/tests/files/logs/courier-auth +@@ -8,3 +8,5 @@ Nov 13 08:11:53 server imapd-ssl: LOGIN FAILED, user=user@domain.tld, ip=[::ffff + Apr 17 19:17:11 SERVER courierpop3login: LOGIN FAILED, user=USER@EXAMPLE.org, ip=[::ffff:1.2.3.4] + # failJSON: { "time": "2005-04-17T19:17:12", "match": true , "host": "192.0.2.4" } + Apr 17 19:17:12 server imapd-ssl: LOGIN FAILED, method=PLAIN, ip=[::ffff:192.0.2.4] ++# failJSON: { "time": "2005-04-27T09:00:00", "match": true , "user": "tester", "host": "192.0.2.5" } ++Apr 27 09:00:00 servername imapd: LOGIN FAILED, user=tester, ip=[::ffff:192.0.2.5], port=[255] diff --git a/debian/patches/fix-race.diff b/debian/patches/fix-race.diff new file mode 100644 index 00000000..27497207 --- /dev/null +++ b/debian/patches/fix-race.diff @@ -0,0 +1,9 @@ +Index: fail2ban/files/fail2ban.service.in +=================================================================== +--- fail2ban.orig/files/fail2ban.service.in ++++ fail2ban/files/fail2ban.service.in +@@ -20,3 +20,4 @@ Environment="PYTHONNOUSERSITE=yes" + + [Install] + WantedBy=multi-user.target ++WantedBy=logrotate.service diff --git a/debian/patches/series b/debian/patches/series index f94f4e73..70aac0d0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -11,3 +11,5 @@ systemd-run.diff scanlogd.patch 997601-use_2to3.diff python3.10.diff +fix-race.diff +courier-auth.diff