From 2e8a75195cecdfca20e4c20751d819dfbbf773c0 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 6 Oct 2024 21:49:28 +0200 Subject: [PATCH] De-duplicate code in read_profile() --- utils/apparmor/aa.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index 5a162ec67..f6d2587cf 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -1685,23 +1685,16 @@ def read_profile(file, active_profile, read_error_fatal=False): attach_profile_data(aa, profile_data) attach_profile_data(original_aa, profile_data) - for profile in profile_data: - attachment = profile_data[profile]['attachment'] - filename = profile_data[profile]['filename'] + for profile in profile_data: + attachment = profile_data[profile]['attachment'] + filename = profile_data[profile]['filename'] - if not attachment and profile.startswith('/'): - attachment = profile # use profile as name and attachment + if not attachment and profile.startswith('/'): + attachment = profile # use profile as name and attachment + if active_profile: active_profiles.add_profile(filename, profile, attachment, profile_data[profile]) - - else: - for profile in profile_data: - attachment = profile_data[profile]['attachment'] - filename = profile_data[profile]['filename'] - - if not attachment and profile.startswith('/'): - attachment = profile # use profile as name and attachment - + else: extra_profiles.add_profile(filename, profile, attachment, profile_data[profile])