From fe1fb7caa3b6f01cf5600993324b4c7de79547cc Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 12 Nov 2017 20:22:49 +0100 Subject: [PATCH] Fix sorted() regression in save_profiles() The last change in save_profiles() sorted() the order in which the changed profiles get displayed. However, it did not honor the sorting when displaying changes or saving the selected profile, leading to the wrong profile displayed or saved. This patch fixes picking the selected profile, and at the same time replaces the duplicated code for doing this with a single instance. I propose this patch for trunk and 2.11. Note that the 2.11 branch needs a slightly different patch (different indentation). Also note that this regression made it into 2.11.1, so distributions shipping 2.11.1 should add this patch. --- utils/apparmor/aa.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index 42ef41ac6..c865a20d2 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -1823,16 +1823,18 @@ def save_profiles(): if not changed: return - q.options = sorted(changed.keys()) + options = sorted(changed.keys()) + q.options = options ans, arg = q.promptUser() + + which = options[arg] + if ans == 'CMD_SAVE_SELECTED': - profile_name = list(changed.keys())[arg] - write_profile_ui_feedback(profile_name) - reload_base(profile_name) + write_profile_ui_feedback(which) + reload_base(which) elif ans == 'CMD_VIEW_CHANGES': - which = list(changed.keys())[arg] oldprofile = None if aa[which][which].get('filename', False): oldprofile = aa[which][which]['filename'] @@ -1848,7 +1850,6 @@ def save_profiles(): aaui.UI_Changes(oldprofile, newprofile, comments=True) elif ans == 'CMD_VIEW_CHANGES_CLEAN': - which = list(changed.keys())[arg] oldprofile = serialize_profile(original_aa[which], which, '') newprofile = serialize_profile(aa[which], which, '')