From cf4eb0182cdc6944764f1fe547b6fb6fb1cf0c89 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Fri, 29 May 2015 23:29:52 +0200 Subject: [PATCH] severity.py: change rank_capability() to not expect the CAP_ prefix Change rank_capability() so that it doesn't expect the CAP_ prefix. This makes usage easier because callers can simply hand over the capability name. Also change rank() to call rank_capability() without the CAP_ prefix. Acked-by: Steve Beattie --- utils/apparmor/severity.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/apparmor/severity.py b/utils/apparmor/severity.py index fb6101e56..0dbab2165 100644 --- a/utils/apparmor/severity.py +++ b/utils/apparmor/severity.py @@ -77,7 +77,7 @@ class Severity(object): def rank_capability(self, resource): """Returns the severity of for the capability resource, default value if no match""" - cap = resource.upper() + cap = 'CAP_%s' % resource.upper() if cap in self.severity['CAPABILITIES'].keys(): return self.severity['CAPABILITIES'][cap] # raise ValueError("unexpected capability rank input: %s"%resource) @@ -136,7 +136,7 @@ class Severity(object): elif resource[0] == '/': # file resource return self.handle_file(resource, mode) elif resource[0:4] == 'CAP_': # capability resource - return self.rank_capability(resource) + return self.rank_capability(resource[4:]) else: raise AppArmorException("Unexpected rank input: %s" % resource)