From 103be8e14bfc46f9ca5d9a1663ffb63bb730a886 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 23 Apr 2023 14:41:01 +0200 Subject: [PATCH] Fix error when choosing named exec with plane profile names When a user choooses to execute to a named profile (not: named child), make sure to get the profile filename in the correct way to avoid a crash. Fixes: https://gitlab.com/apparmor/apparmor/-/issues/314 --- utils/apparmor/aa.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index ebb62dd87..4506b3790 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -1038,7 +1038,12 @@ def ask_exec(hashlog): hashlog[aamode][target_profile]['final_name'] = exec_target # Check profile exists for px - if not os.path.exists(get_profile_filename_from_attachment(exec_target, True)): + if exec_target.startswith(('/', '@', '{')): + prof_filename = get_profile_filename_from_attachment(exec_target, True) + else: # named exec + prof_filename = get_profile_filename_from_profile_name(exec_target, True) + + if not os.path.exists(prof_filename): ynans = 'y' if 'i' in exec_mode: ynans = aaui.UI_YesNo(_('A profile for %s does not exist.\nDo you want to create one?') % exec_target, 'n')