2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-30 13:58:22 +00:00

change_profile_flags: raise AppArmorBug on empty new flag

This commit is contained in:
Christian Boltz
2018-07-25 22:30:13 +02:00
parent c016fc6656
commit d26ffbdd29
2 changed files with 3 additions and 3 deletions

View File

@@ -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)

View File

@@ -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):