mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 14:25:52 +00:00
change_profile_flags: raise AppArmorBug on empty new flag
This commit is contained in:
@@ -639,8 +639,8 @@ def change_profile_flags(prof_filename, program, flag, set_flag):
|
|||||||
|
|
||||||
found = False
|
found = False
|
||||||
|
|
||||||
if newflags and newflags.strip() == '':
|
if not flag or flag.strip() == '':
|
||||||
raise AppArmorBug('New flags for %s contain only whitespace' % prof_filename)
|
raise AppArmorBug('New flag for %s is empty' % prof_filename)
|
||||||
|
|
||||||
with open_file_read(prof_filename) as f_in:
|
with open_file_read(prof_filename) as f_in:
|
||||||
temp_file = tempfile.NamedTemporaryFile('w', prefix=prof_filename, suffix='~', delete=False, dir=profile_dir)
|
temp_file = tempfile.NamedTemporaryFile('w', prefix=prof_filename, suffix='~', delete=False, dir=profile_dir)
|
||||||
|
@@ -367,7 +367,7 @@ class AaTest_change_profile_flags(AaTestWithTempdir):
|
|||||||
# XXX empty new flag should raise AppArmorBug
|
# XXX empty new flag should raise AppArmorBug
|
||||||
self._test_change_profile_flags('/foo', '( )', '', True, '', check_new_flags=False)
|
self._test_change_profile_flags('/foo', '( )', '', True, '', check_new_flags=False)
|
||||||
def test_change_profile_flags_invalid_04(self):
|
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
|
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):
|
def test_change_profile_flags_other_profile(self):
|
||||||
|
Reference in New Issue
Block a user