[apparmor] [patch] utils: make aa-status(8) function without python3-apparmor
Seth Arnold
seth.arnold at canonical.com
Sat Aug 1 00:55:00 UTC 2015
On Fri, Jul 31, 2015 at 05:26:25PM -0700, Steve Beattie wrote:
> If python3-apparmor is not installed, aa-status aborts due to the added
> import to handle fancier exception handling failing. This patch makes
> aa-status(8) work even in that case, falling back to normal python
> exceptions, to keep its required dependencies as small as possible.
>
> Signed-off-by: Steve Beattie <steve at nxnw.org>
Acked-by: Seth Arnold <seth.arnold at canonical.com>
Nice fix; rewriting aa-status in C makes sense, but putting that
hypothetical change into 2.10 probably doesn't make sense. This is short
and does the job.
Thanks
> ---
> utils/aa-status | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> Index: b/utils/aa-status
> ===================================================================
> --- a/utils/aa-status
> +++ b/utils/aa-status
> @@ -12,9 +12,19 @@
>
> import re, os, sys, errno
>
> +# PLEASE NOTE: we try to keep aa-status as minimal as possible, for
> +# environments where installing all of the python utils and python
> +# apparmor module may not make sense. Please think carefully before
> +# importing anything from apparmor; see how the apparmor.fail import is
> +# handled below.
> +
> # setup exception handling
> -from apparmor.fail import enable_aa_exception_handler
> -enable_aa_exception_handler()
> +try:
> + from apparmor.fail import enable_aa_exception_handler
> + enable_aa_exception_handler()
> +except ImportError:
> + # just let normal python exceptions happen (LP: #1480492)
> + pass
>
> def cmd_enabled():
> '''Returns error code if AppArmor is not enabled'''
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150731/b6aa27d4/attachment.pgp>
More information about the AppArmor
mailing list