From d26ffbdd2911bd311c70a9236bd130a0449308a1 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Wed, 25 Jul 2018 22:30:13 +0200 Subject: [PATCH] change_profile_flags: raise AppArmorBug on empty new flag --- utils/apparmor/aa.py | 4 ++-- utils/test/test-aa.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index 9a5d1c5c7..58e68f7d3 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -639,8 +639,8 @@ def change_profile_flags(prof_filename, program, flag, set_flag): found = False - if newflags and newflags.strip() == '': - raise AppArmorBug('New flags for %s contain only whitespace' % prof_filename) + if not flag or flag.strip() == '': + raise AppArmorBug('New flag for %s is empty' % prof_filename) with open_file_read(prof_filename) as f_in: temp_file = tempfile.NamedTemporaryFile('w', prefix=prof_filename, suffix='~', delete=False, dir=profile_dir) diff --git a/utils/test/test-aa.py b/utils/test/test-aa.py index 157a717f4..8e3f16905 100644 --- a/utils/test/test-aa.py +++ b/utils/test/test-aa.py @@ -367,7 +367,7 @@ class AaTest_change_profile_flags(AaTestWithTempdir): # XXX empty new flag should raise AppArmorBug self._test_change_profile_flags('/foo', '( )', '', True, '', check_new_flags=False) def test_change_profile_flags_invalid_04(self): - # with self.assertRaises(AppArmorBug): # XXX empty new flag should raise AppArmorBug + with self.assertRaises(AppArmorBug): self._test_change_profile_flags('/foo', 'flags=(complain, audit)', ' ', True, 'audit, complain', check_new_flags=False) # whitespace-only newflags def test_change_profile_flags_other_profile(self):