diff --git a/debian/patches/0001-BF-RF-test-for-being-a-root-to-check-if-actually-can.patch b/debian/patches/0001-BF-RF-test-for-being-a-root-to-check-if-actually-can.patch new file mode 100644 index 00000000..cc46b2f6 --- /dev/null +++ b/debian/patches/0001-BF-RF-test-for-being-a-root-to-check-if-actually-can.patch @@ -0,0 +1,34 @@ +From bd457781df3442b6721360a9f190428994292e15 Mon Sep 17 00:00:00 2001 +From: Yaroslav Halchenko +Date: Sun, 21 Jan 2018 22:01:24 -0500 +Subject: [PATCH] BF: RF test for "being a root" to check if actually can read + the file + +--- + fail2ban/tests/filtertestcase.py | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/fail2ban/tests/filtertestcase.py b/fail2ban/tests/filtertestcase.py +index b707beb5..40cf51f9 100644 +--- a/fail2ban/tests/filtertestcase.py ++++ b/fail2ban/tests/filtertestcase.py +@@ -675,7 +675,15 @@ class LogFileMonitor(LogCaptureTestCase): + os.chmod(self.name, 0) + self.filter.getFailures(self.name) + failure_was_logged = self._is_logged('Unable to open %s' % self.name) +- is_root = getpass.getuser() == 'root' ++ # verify that we cannot access the file. Checking by name of user is not ++ # sufficient since could be a fakeroot or some other super-user ++ try: ++ with open(self.name) as f: ++ f.read() ++ is_root = True ++ except IOError: ++ is_root = False ++ + # If ran as root, those restrictive permissions would not + # forbid log to be read. + self.assertTrue(failure_was_logged != is_root) +-- +2.15.1 + diff --git a/debian/patches/series b/debian/patches/series index fce52816..3435f5f7 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -5,3 +5,4 @@ deb_manpages_reportbug 0002-ENH-verify-that-use_stock_cfg-was-not-provided-while.patch 0003-BF-look-for-system.journal-also-under-system-state-l.patch 0004-BF-use-build_-_2to3-if-in-_2to3.patch +0001-BF-RF-test-for-being-a-root-to-check-if-actually-can.patch