2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 06:16:03 +00:00

When changing flags, use correct amount of whitespace

.. instead of preserving the original leading whitespace.

This change affects the behaviour of aa-complain, aa-enforce and aa-audit.
This commit is contained in:
Christian Boltz
2021-05-23 19:00:06 +02:00
parent 0325ba06da
commit f0a445dd7d
2 changed files with 10 additions and 5 deletions

View File

@@ -257,7 +257,7 @@ class AaTest_change_profile_flags(AaTestWithTempdir):
dummy_profile_content = ' #include <abstractions/base>\n capability chown,\n /bar r,'
prof_template = '%s%s%s {%s\n%s\n%s\n}\n'
old_prof = prof_template % (whitespace, profile, old_flags, comment, more_rules, dummy_profile_content)
new_prof = prof_template % (whitespace, profile, expected_flags, comment, expected_more_rules, dummy_profile_content)
new_prof = prof_template % ('', profile, expected_flags, comment, expected_more_rules, dummy_profile_content)
self.file = write_file(self.tmpdir, 'profile', old_prof)
change_profile_flags(self.file, profile_name, flags_to_change, set_flag)
@@ -333,7 +333,7 @@ class AaTest_change_profile_flags(AaTestWithTempdir):
def test_change_profile_flags_with_hat_03(self):
self._test_change_profile_flags('/foo', 'flags=(complain)', 'audit', True, 'audit, complain',
more_rules='\n^foobar (attach_disconnected) { # comment\n}\n',
expected_more_rules='\n^foobar flags=(attach_disconnected, audit) { # comment\n}\n'
expected_more_rules='\n ^foobar flags=(attach_disconnected, audit) { # comment\n}\n'
)
def test_change_profile_flags_with_hat_04(self):