mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 05:47:59 +00:00
utils: handle versioned ruby interpreters
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@nxnw.org> Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
parent
61a7b23757
commit
db00c37351
@ -435,7 +435,7 @@ def get_interpreter_and_abstraction(exec_target):
|
|||||||
abstraction = 'abstractions/perl'
|
abstraction = 'abstractions/perl'
|
||||||
elif re.search('^python([23]|[23]\.[0-9]+)?$', interpreter):
|
elif re.search('^python([23]|[23]\.[0-9]+)?$', interpreter):
|
||||||
abstraction = 'abstractions/python'
|
abstraction = 'abstractions/python'
|
||||||
elif interpreter == 'ruby':
|
elif re.search('^ruby([0-9]+(\.[0-9]+)*)?$', interpreter):
|
||||||
abstraction = 'abstractions/ruby'
|
abstraction = 'abstractions/ruby'
|
||||||
else:
|
else:
|
||||||
abstraction = None
|
abstraction = None
|
||||||
|
@ -115,6 +115,8 @@ class AaTest_get_interpreter_and_abstraction(AATest):
|
|||||||
('#!/usr/bin/python3', ('/usr/bin/python3', 'abstractions/python')),
|
('#!/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/python4', ('/usr/bin/python4', None)), # python abstraction is only applied to py2 and py3
|
||||||
('#!/usr/bin/ruby', ('/usr/bin/ruby', 'abstractions/ruby')),
|
('#!/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"
|
('#!/usr/bin/foobarbaz', ('/usr/bin/foobarbaz', None)), # we don't have an abstraction for "foobarbaz"
|
||||||
('foo', (None, None)), # no hashbang - not a script
|
('foo', (None, None)), # no hashbang - not a script
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user