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

utils: Handle unmount rules

Bug: https://bugs.launchpad.net/bugs/1325109

The parser will accept rules with either umount or unmount rule types.
The utils should follow suite.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
This commit is contained in:
Tyler Hicks
2014-06-03 16:23:30 -05:00
parent 4bff5778e0
commit d2b62fff47
3 changed files with 15 additions and 1 deletions

View File

@@ -2627,7 +2627,7 @@ RE_PROFILE_HAT_DEF = re.compile('^\s*\^(\"??.+?\"??)\s+((flags=)?\((.+)\)\s+)*\{
RE_NETWORK_FAMILY_TYPE = re.compile('\s+(\S+)\s+(\S+)\s*,$')
RE_NETWORK_FAMILY = re.compile('\s+(\S+)\s*,$')
RE_PROFILE_DBUS = re.compile('^\s*(audit\s+)?(allow\s+|deny\s+)?(dbus\s*,|dbus\s+[^#]*\s*,)\s*(#.*)?$')
RE_PROFILE_MOUNT = re.compile('^\s*(audit\s+)?(allow\s+|deny\s+)?((mount|remount|umount)(\s+[^#]*)?\s*,)\s*(#.*)?$')
RE_PROFILE_MOUNT = re.compile('^\s*(audit\s+)?(allow\s+|deny\s+)?((mount|remount|umount|unmount)(\s+[^#]*)?\s*,)\s*(#.*)?$')
RE_PROFILE_SIGNAL = re.compile('^\s*(audit\s+)?(allow\s+|deny\s+)?(signal\s*,|signal\s+[^#]*\s*,)\s*(#.*)?$')
RE_PROFILE_PTRACE = re.compile('^\s*(audit\s+)?(allow\s+|deny\s+)?(ptrace\s*,|ptrace\s+[^#]*\s*,)\s*(#.*)?$')
RE_PROFILE_PIVOT_ROOT = re.compile('^\s*(audit\s+)?(allow\s+|deny\s+)?(pivot_root\s*,|pivot_root\s+[^#]*\s*,)\s*(#.*)?$')

View File

@@ -66,5 +66,17 @@ class AAParseUmountTest(unittest.TestCase):
self.assertEqual(rule, mount.serialize(),
'mount object returned "%s", expected "%s"' % (mount.serialize(), rule))
def test_parse_plain_unmount_rule(self):
rule = 'unmount,'
mount = aa.parse_mount_rule(rule)
self.assertEqual(rule, mount.serialize(),
'mount object returned "%s", expected "%s"' % (mount.serialize(), rule))
def test_parse_unmount_with_mount_point(self):
rule = 'unmount /mnt/external,'
mount = aa.parse_mount_rule(rule)
self.assertEqual(rule, mount.serialize(),
'mount object returned "%s", expected "%s"' % (mount.serialize(), rule))
if __name__ == '__main__':
unittest.main()

View File

@@ -249,6 +249,8 @@ class AARegexMount(unittest.TestCase):
(' audit mount,', ('audit', None, 'mount,', 'mount', None, None)),
(' umount,', (None, None, 'umount,', 'umount', None, None)),
(' audit umount,', ('audit', None, 'umount,', 'umount', None, None)),
(' unmount,', (None, None, 'unmount,', 'unmount', None, None)),
(' audit unmount,', ('audit', None, 'unmount,', 'unmount', None, None)),
(' remount,', (None, None, 'remount,', 'remount', None, None)),
(' deny remount,', (None, 'deny', 'remount,', 'remount', None, None)),