From 7b07832459d0a8f7f606b7ee3ef69b6409cbf6f7 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Mon, 22 Oct 2018 23:11:22 +0200 Subject: [PATCH] Move updating existing_profiles out of parse_profile_data() parse_profile_data() returns the parsed profiles, but writes to existing_profiles directly. read_profiles() calls parse_profile_data() and already handles adding the parsed profiles to aa, original_aa or extras, which means updating existing_profiles there is a much better place. This commit also includes a hidden change: Previously, when parsing include files, they were also added to existing_profiles. This is superfluous, only real profiles need to be stored there. (cherry picked from commit 8809218ac8cfb89a6c8b2109511960c8aab944aa) --- utils/apparmor/aa.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index ce9a674b4..72ebb4817 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -2106,9 +2106,21 @@ def read_profile(file, active_profile): if profile_data and active_profile: attach_profile_data(aa, profile_data) attach_profile_data(original_aa, profile_data) + + for profile in profile_data: # TODO: also honor hats + name = profile_data[profile][profile]['name'] + filename = profile_data[profile][profile]['filename'] + + existing_profiles[name] = filename + elif profile_data: attach_profile_data(extras, profile_data) + for profile in profile_data: # TODO: also honor hats + name = profile_data[profile][profile]['name'] + filename = profile_data[profile][profile]['filename'] + + existing_profiles[name] = filename def attach_profile_data(profiles, profile_data): # Make deep copy of data to avoid changes to @@ -2200,9 +2212,6 @@ def parse_profile_data(data, file, do_include): if pps_set_hat_external: profile_data[profile][hat]['external'] = True - # Profile stored - existing_profiles[profile] = file - # save profile name and filename profile_data[profile][hat]['name'] = profile profile_data[profile][hat]['filename'] = file