[apparmor] [PATCH 1/3] utils: Basic support for signal rules

Tyler Hicks tyhicks at canonical.com
Fri Apr 4 18:15:51 UTC 2014


On 2014-04-04 10:54:54, Steve Beattie wrote:
> On Thu, Apr 03, 2014 at 02:55:59PM -0500, Tyler Hicks wrote:
> > Bug: https://bugs.launchpad.net/bugs/1300316
> > 
> > This patch does bare bones parsing of signal 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 signal rules.
> > 
> > Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
> Acked-by: Steve Beattie <steve at nxnw.org>

Thanks!

> 
> One minor nit below:
> 
> > --- /dev/null
> > +++ b/utils/test/test-signal_parse.py
> > @@ -0,0 +1,63 @@
> > +#! /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 AAParseSignalTest(unittest.TestCase):
> > +
> > +    def _test_parse_signal_rule(self, rule):
> > +        signal = aa.parse_signal_rule(rule)
> > +        print(signal.serialize())
> 
> I'm assuming this is debugging info? If you added it to see which tests
> were running, you can pass verbosity=2 to unittest.main() instead.

Good catch!

That was debugging info that should have been removed from the final
version of the patch but was left and got copy and pasted into the other
two patches. I'll remove the print statement from all 3 patches before
committing them.

Tyler

> 
> > +        self.assertEqual(rule, signal.serialize(),
> > +                'signal object returned "%s", expected "%s"' % (signal.serialize(), rule))
> > +
> > +    def test_parse_plain_signal_rule(self):
> > +        self._test_parse_signal_rule('signal,')
> > +
> > +    def test_parse_receive_signal_rule(self):
> > +        self._test_parse_signal_rule('signal (receive),')
> > +
> > +    def test_parse_send_signal_rule(self):
> > +        self._test_parse_signal_rule('signal (send),')
> > +
> > +    def test_parse_send_receive_signal_rule(self):
> > +        self._test_parse_signal_rule('signal (send receive),')
> > +
> > +    def test_parse_r_signal_rule(self):
> > +        self._test_parse_signal_rule('signal r,')
> > +
> > +    def test_parse_w_signal_rule(self):
> > +        self._test_parse_signal_rule('signal w,')
> > +
> > +    def test_parse_rw_signal_rule(self):
> > +        self._test_parse_signal_rule('signal rw,')
> > +
> > +    def test_parse_set_1_signal_rule(self):
> > +        self._test_parse_signal_rule('signal send set=("hup"),')
> > +
> > +    def test_parse_set_2_signal_rule(self):
> > +        self._test_parse_signal_rule('signal (receive) set=kill,')
> > +
> > +    def test_parse_set_3_signal_rule(self):
> > +        self._test_parse_signal_rule('signal w set=(quit int),')
> > +
> > +    def test_parse_peer_1_signal_rule(self):
> > +        self._test_parse_signal_rule('signal receive peer=foo,')
> > +
> > +    def test_parse_peer_2_signal_rule(self):
> > +        self._test_parse_signal_rule('signal (send receive) peer=/usr/bin/bar,')
> > +
> > +    def test_parse_peer_3_signal_rule(self):
> > +        self._test_parse_signal_rule('signal wr set=(pipe, usr1) peer=/sbin/baz,')
> > +
> > +if __name__ == '__main__':
> > +    unittest.main()
> 
> Thanks!
> 
> -- 
> Steve Beattie
> <sbeattie at ubuntu.com>
> http://NxNW.org/~steve/



> -- 
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140404/5721ca55/attachment.pgp>


More information about the AppArmor mailing list