[apparmor] [patch] move quote_if_needed() to apparmor.rule

Seth Arnold seth.arnold at canonical.com
Fri May 8 23:11:15 UTC 2015


On Fri, May 08, 2015 at 11:56:46PM +0200, Christian Boltz wrote:
> Hello,
> 
> quote_if_needed() will be used by the upcoming ChangeProfileRule class,
> which means it must moved out of aa.py to avoid an import loop.
> rule/__init__.py looks like a better place.
> 
> Also re-import quote_if_needed() into aa.py because it's still needed
> there by various functions.
> 
> 
> [ 02-move-quote_if_needed.diff ]

Acked-by: Seth Arnold <seth.arnold at canonical.com>


> +++ utils/apparmor/rule/__init__.py     2015-05-08 23:46:26.461767822 +0200
> +def quote_if_needed(data):
> +    '''quote data if it contains whitespace'''
> +    if ' ' in data:
> +        data = '"' + data + '"'
> +    return data

This looks broken to me; the following profile fails to compile:


profile foo {
  file "/foo " bar" r,
}	

while the following profile compiles fine:

profile foo {
  file "/foo \" bar" r,
}	

The quoting mechanism should also escape any " marks within.

Thanks
-------------- 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/20150508/38e383b1/attachment.pgp>


More information about the AppArmor mailing list