From e5169d8f8421b3736c4610ad84c3953596b6d4b3 Mon Sep 17 00:00:00 2001 From: sebres Date: Wed, 16 Aug 2017 11:37:22 +0200 Subject: [PATCH] pyinotify: be sure possible IOError/OSError by remove monitor (log-rotate? normally not raises) are handled properly. --- fail2ban/server/filterpyinotify.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fail2ban/server/filterpyinotify.py b/fail2ban/server/filterpyinotify.py index 41b8be7c..10f51847 100644 --- a/fail2ban/server/filterpyinotify.py +++ b/fail2ban/server/filterpyinotify.py @@ -231,6 +231,9 @@ class FilterPyinotify(FileFilter): return True except KeyError: # pragma: no cover pass + # EnvironmentError is parent of IOError, OSError, etc. + except EnvironmentError as e: # pragma: no cover (normally unreached) + logSys.error("Remove file monitor for %s causes %s", path, e) return False def _addDirWatcher(self, path_dir): @@ -249,6 +252,9 @@ class FilterPyinotify(FileFilter): self.__monitor.rm_watch(wdInt) except KeyError: # pragma: no cover pass + # EnvironmentError is parent of IOError, OSError, etc. + except EnvironmentError as e: # pragma: no cover (normally unreached) + logSys.error("Remove monitor for the parent directory %s causes %s", path_dir, e) logSys.debug("Removed monitor for the parent directory %s", path_dir) ##