Hello,

this patch changes 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.


[ 15-severity-drop-CAP_prefix.diff ]

=== modified file utils/apparmor/severity.py
--- utils/apparmor/severity.py  2015-05-24 14:27:59.746536218 +0200
+++ utils/apparmor/severity.py  2015-05-24 15:07:27.264507915 +0200
@@ -77,7 +77,7 @@
 
     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 @@
         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)
 


Regards,

Christian Boltz
-- 
Die erprobte Strategie der Managementmotivation im Operating [ist] eine,
die ich gerne mit "Teile die Schmerzen" beschrieben möchte. Zum Beispiel
setzt man den Projekteigentümer auf dieselbe Alerting-Methode wie den
Sysadmin, der am Ende Sonntag nachts um 4 Uhr wegen eines Alarms die
vorbeugende Wartung durchführen muß. [...] Wenn wir nun also einen
jungen Projektverantwortlichen haben, bei dem das Handy Sonntag nachts
um vier die Frau und das 6 Monate alte Kind weckt, dann ist diese Person
nach einigen Wochen unmittelbaren Alerting-Erlebens sehr viel zugäng-
licher. [http://blog.koehntopp.de/archives/2859-Wieso-zehn-Prozent.html]


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to