[apparmor] [patch] convert CapabilityRule to using set()s
Steve Beattie
steve at nxnw.org
Tue Nov 25 21:26:22 UTC 2014
On Mon, Nov 24, 2014 at 12:46:11PM -0800, Steve Beattie wrote:
> In python, a set() is very similar to a list, except that it guarantees
> uniqueness amongst its member elements (which means that there's an
> additional constraint that the elements have to be hashable). As a
> bonus, you also have common set operations available, like issubset(),
> issuperset(), union(), intersection(), etc. These may be really helpful
> for dealing with capability rules that contain multiple capabilities.
>
> See https://docs.python.org/3/library/stdtypes.html#set for details.
Attached is a patch that converts from using a list to using a set(). It
doesn't take much advantage of that ability, other than to use
issubset() instead of manually walking the list and confirming that all
elements of one rule are in another. But more interesting stuff could be
done to delete a multi-capability subset from another superset
capability rule, if need be.
Signed-off-by: Steve Beattie <steve at nxnw.org>
--
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: utils-convert_to_using_set.patch
Type: text/x-diff
Size: 5615 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20141125/718e85d1/attachment-0001.patch>
-------------- 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/20141125/718e85d1/attachment-0001.pgp>
More information about the AppArmor
mailing list