mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 10:07:12 +00:00
Bug: https://bugs.launchpad.net/bugs/1298678 This patch does bare bones parsing of pivot_root rules and stores the raw strings for writing them out later. It is meant to be a simple change to prevent aa.py from emitting a traceback when encountering pivot_root rules. Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Acked-by: Steve Beattie <steve@nxnw.org> Acked-By: Christian Boltz <apparmor@cboltz.de>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
#! /usr/bin/env python
|
|
# ------------------------------------------------------------------
|
|
#
|
|
# Copyright (C) 2014 Canonical Ltd.
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of version 2 of the GNU General Public
|
|
# License published by the Free Software Foundation.
|
|
#
|
|
# ------------------------------------------------------------------
|
|
|
|
import apparmor.aa as aa
|
|
import unittest
|
|
|
|
class AAParsePivotRootTest(unittest.TestCase):
|
|
|
|
def _test_parse_pivot_root_rule(self, rule):
|
|
pivot_root = aa.parse_pivot_root_rule(rule)
|
|
self.assertEqual(rule, pivot_root.serialize(),
|
|
'pivot_root object returned "%s", expected "%s"' % (pivot_root.serialize(), rule))
|
|
|
|
def test_parse_plain_pivot_root_rule(self):
|
|
self._test_parse_pivot_root_rule('pivot_root,')
|
|
|
|
def test_parse_old_pivot_root_rule(self):
|
|
self._test_parse_pivot_root_rule('pivot_root /old,')
|
|
|
|
def test_parse_new_pivot_root_rule(self):
|
|
self._test_parse_pivot_root_rule('pivot_root /old /new,')
|
|
|
|
def test_parse_child_pivot_root_rule(self):
|
|
self._test_parse_pivot_root_rule('pivot_root /old /new -> /usr/bin/child,')
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|