From f472b6bb3422fd13d3039a8f4c83d017a2d660e3 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sat, 14 Apr 2018 21:45:39 +0200 Subject: [PATCH] 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. --- utils/apparmor/aa.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index 4545dfc7d..e28b8495a 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,