[apparmor] [patch] better error messages in aa.py store_list_var()

Steve Beattie steve at nxnw.org
Thu Jun 19 00:52:02 UTC 2014


On Thu, Jun 19, 2014 at 02:41:39AM +0200, Christian Boltz wrote:
> this patch improves the error messages in aa.py store_list_var() to make
> debugging of profile syntax problems easier.

This is an okay improvement as-is, but it sure would be nice if we
could the name of the problematic file being parsed attached to the
exception.  Maybe in a try-except block, the callers could re-raise
the exception with the filename attached?

> === modified file 'utils/apparmor/aa.py'
> --- utils/apparmor/aa.py        2014-06-09 22:44:59 +0000
> +++ utils/apparmor/aa.py        2014-06-19 00:36:11 +0000
> @@ -3245,14 +3245,14 @@
>              var[list_var] = set(vlist)
>          else:
>              #print('Ignored: New definition for variable for:',list_var,'=', value, 'operation was:',var_operation,'old value=', var[list_var])
> -            raise AppArmorException(_('An existing variable redefined: %s') % list_var)
> +            raise AppArmorException(_('Redefining existing variable %s: %s') % (list_var, value))
>      elif var_operation == '+=':
>          if var.get(list_var, False):
>              var[list_var] = set(var[list_var] + vlist)
>          else:
> -            raise AppArmorException(_('Values added to a non-existing variable: %s') % list_var)
> +            raise AppArmorException(_('Values added to a non-existing variable %s: %s') % (list_var, value))
>      else:
> -        raise AppArmorException(_('Unknown variable operation: %s') % var_operation)
> +        raise AppArmorException(_('Unknown variable operation %s for variable %s') % (var_operation, list_var))
>  
>  
>  def strip_quotes(data):
> 
> 
> 
> Regards,
> 
> Christian Boltz
> -- 
> [BILD] Als langjährig tätiger Strafverteidiger (und Fan von Volker
> Pispers) muß ich jedoch dringend davor warnen, stinkende tote Fische in
> dieses Freiexemplar der sogenannten "Zeitung" einzuwickeln. Weil das ein
> Strafverfahren wegen Beleidigung zulasten des Fisches nach sich ziehen
> könnte.
> [http://www.kanzlei-hoenig.de/2012/keine-stinkende-tote-fische-im-briefkasten/]
> 
> 
> -- 
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor

-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- 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/20140618/0627751d/attachment.pgp>


More information about the AppArmor mailing list