From c7ddf1f940aa30f7d31dc1bf6e4d895713a6e38b Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 19 May 2017 15:36:06 +0200 Subject: [PATCH] [systemd-backend] implicit closing journal descriptor by stop filter. Partially cherry-picked from 0.10 (d153555a07ec81dabe4678ea06c8e644afc8ec40) --- ChangeLog | 2 ++ fail2ban/server/filtersystemd.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8e7ebdb0..c798768d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,8 @@ releases. ### Fixes +* Fix for systemd-backend: fail2ban hits the ulimit (out of file descriptors), see gh-991. + Partially back-ported from v.0.10. ### New Features diff --git a/fail2ban/server/filtersystemd.py b/fail2ban/server/filtersystemd.py index 908112a7..73db618e 100644 --- a/fail2ban/server/filtersystemd.py +++ b/fail2ban/server/filtersystemd.py @@ -291,6 +291,13 @@ class FilterSystemd(JournalFilter): # pragma: systemd no cover except FailManagerEmpty: self.failManager.cleanup(MyTime.time()) + # close journal: + try: + if self.__journal: + self.__journal.close() + except Exception as e: # pragma: no cover + logSys.error("Close journal failed: %r", e, + exc_info=logSys.getEffectiveLevel()<=logging.DEBUG) logSys.debug((self.jail is not None and self.jail.name or "jailless") +" filter terminated") return True