[apparmor] [patch] move quote_if_needed() to apparmor.rule
Christian Boltz
apparmor at cboltz.de
Fri May 8 21:56:46 UTC 2015
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 ]
=== modified file utils/apparmor/aa.py
--- utils/apparmor/aa.py 2015-04-24 22:05:14.740650852 +0200
+++ utils/apparmor/aa.py 2015-05-08 23:46:46.416595416 +0200
@@ -55,7 +55,7 @@
from apparmor.rule.capability import CapabilityRuleset, CapabilityRule
from apparmor.rule.network import NetworkRuleset, NetworkRule
-from apparmor.rule import parse_modifiers
+from apparmor.rule import parse_modifiers, quote_if_needed
from apparmor.yasti import SendDataToYast, GetDataFromYast, shutdown_yast
@@ -3210,12 +3210,6 @@
raise AppArmorException(_('Unknown variable operation %(operation)s for variable %(variable)s in %(file)s') % { 'operation': var_operation, 'variable': list_var, 'file': filename })
-def quote_if_needed(data):
- # quote data if it contains whitespace
- if ' ' in data:
- data = '"' + data + '"'
- return data
-
def escape(escape):
escape = strip_quotes(escape)
escape = re.sub('((?<!\\))"', r'\1\\', escape)
=== modified file utils/apparmor/rule/__init__.py
--- utils/apparmor/rule/__init__.py 2015-04-25 00:00:59.772054000 +0200
+++ utils/apparmor/rule/__init__.py 2015-05-08 23:46:26.461767822 +0200
@@ -316,3 +316,10 @@
comment = ' %s' % matches.group('comment')
return (audit, deny, allow_keyword, comment)
+
+def quote_if_needed(data):
+ '''quote data if it contains whitespace'''
+ if ' ' in data:
+ data = '"' + data + '"'
+ return data
+
Regards,
Christian Boltz
--
> [feste Stringlängen in C] Dafür gibt's #defines.
Und jedesmal ein neuer Build, wenn sich irgendwo eine Länge ändert.
Cool! Den Versionszähler kann man sich dann als Ventilator in die
Küche hängen ;-) [> Thorsten Haude und Jan Trippler in suse-linux]
More information about the AppArmor
mailing list