File fix-regression-in-set-flags.patch of Package apparmor.9207
commit f472b6bb3422fd13d3039a8f4c83d017a2d660e3
Author: Christian Boltz <apparmor@cboltz.de>
Date: Sat Apr 14 21:45:39 2018 +0200
fix regression in {get,set}_profile_flags()
Since the latest change, calling {get,set}_profile_flags() with the
profile name failed when attachment was specified ("profile foo /bar").
Catched by the unittests.
Also fix a whitespace issue.
diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py
index 4545dfc7..e28b8495 100644
--- a/utils/apparmor/aa.py
+++ b/utils/apparmor/aa.py
@@ -617,7 +617,7 @@ def get_profile_flags(filename, program):
else:
profile_glob = AARE(matches['profile'], True)
flags = matches['flags']
- if (program is not None and profile_glob.match(program)) or program is None:
+ if (program is not None and profile_glob.match(program)) or program is None or program == matches['profile']:
return flags
raise AppArmorException(_('%s contains no profile') % filename)
@@ -674,10 +674,11 @@ def set_profile_flags(prof_filename, program, newflags):
profile_glob = AARE(matches['attachment'], True)
else:
profile_glob = AARE(matches['profile'], True)
- if (program is not None and profile_glob.match(program)) or program is None:
+ if (program is not None and profile_glob.match(program)) or program is None or program == matches['profile']:
found = True
if program is not None and program != profile:
- aaui.UI_Info(_('Warning: profile %s represents multiple programs') % profile)
+ aaui.UI_Info(_('Warning: profile %s represents multiple programs') % profile)
+
header_data = {
'attachment': matches['attachment'] or '',
'flags': newflags,