[apparmor] [patch] utils: handle versioned ruby interpreters

Seth Arnold seth.arnold at canonical.com
Tue Jan 26 00:18:09 UTC 2016


On Mon, Jan 25, 2016 at 04:14:29PM -0800, Steve Beattie wrote:
> On Debian and Ubuntu it's possible to have multiple ruby interpreters
> installed, and the default to use is handled by the ruby-defaults
> package, which includes a symlink from /usr/bin/ruby to the versioned
> ruby interpreter.
> 
> This patch makes aa.py:get_interpreter_and_abstraction() take that into
> account by using a regex to match possible versions of ruby. Testcases
> are included. (I noticed this lack of support because on Ubuntu the ruby
> test was failing because get_interpreter_and_abstraction() would get the
> complete path, which on my 16.04 laptop would get /usr/bin/ruby2.2.)
> 
> Signed-off-by: Steve Beattie <steve at nxnw.org>

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

THanks

> ---
>  utils/apparmor/aa.py  |    2 +-
>  utils/test/test-aa.py |    2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> Index: b/utils/apparmor/aa.py
> ===================================================================
> --- a/utils/apparmor/aa.py
> +++ b/utils/apparmor/aa.py
> @@ -435,7 +435,7 @@ def get_interpreter_and_abstraction(exec
>          abstraction = 'abstractions/perl'
>      elif re.search('^python([23]|[23]\.[0-9]+)?$', interpreter):
>          abstraction = 'abstractions/python'
> -    elif interpreter == 'ruby':
> +    elif re.search('^ruby([0-9]+(\.[0-9]+)*)?$', interpreter):
>          abstraction = 'abstractions/ruby'
>      else:
>          abstraction = None
> Index: b/utils/test/test-aa.py
> ===================================================================
> --- a/utils/test/test-aa.py
> +++ b/utils/test/test-aa.py
> @@ -115,6 +115,8 @@ class AaTest_get_interpreter_and_abstrac
>          ('#!/usr/bin/python3',      ('/usr/bin/python3',    'abstractions/python')),
>          ('#!/usr/bin/python4',      ('/usr/bin/python4',    None)),  # python abstraction is only applied to py2 and py3
>          ('#!/usr/bin/ruby',         ('/usr/bin/ruby',       'abstractions/ruby')),
> +        ('#!/usr/bin/ruby2.2',      ('/usr/bin/ruby2.2',    'abstractions/ruby')),
> +        ('#!/usr/bin/ruby1.9.1',    ('/usr/bin/ruby1.9.1',  'abstractions/ruby')),
>          ('#!/usr/bin/foobarbaz',    ('/usr/bin/foobarbaz',  None)),  # we don't have an abstraction for "foobarbaz"
>          ('foo',                     (None,                  None)),  # no hashbang - not a script
>      ]
-------------- 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/20160125/978de7f5/attachment.pgp>


More information about the AppArmor mailing list