Hello, 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), therefore I'm attaching both versions. Also note that this regression made it into 2.11.1, so distributions shipping 2.11.1 should apply this patch. [ 04-fix-sorted-save_profiles-regression.diff ] --- utils/apparmor/aa.py 2017-10-11 21:20:00.789641479 +0200 +++ utils/apparmor/aa.py 2017-10-22 14:15:00.412193634 +0200 @@ -1827,16 +1827,18 @@ 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'] @@ -1852,7 +1854,6 @@ display_changes_with_comments(oldprofile, newprofile) elif ans == 'CMD_VIEW_CHANGES_CLEAN': - which = list(changed.keys())[arg] oldprofile = serialize_profile(original_aa[which], which, '') newprofile = serialize_profile(aa[which], which, '') [ 04-fix-sorted-save_profiles-regression.diff-2.11 ] --- utils/apparmor/aa.py 2017-10-11 21:20:00.789641479 +0200 +++ utils/apparmor/aa.py 2017-10-22 14:15:00.412193634 +0200 @@ -1827,16 +1827,18 @@ 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'] @@ -1852,7 +1854,6 @@ display_changes_with_comments(oldprofile, newprofile) elif ans == 'CMD_VIEW_CHANGES_CLEAN': - which = list(changed.keys())[arg] oldprofile = serialize_profile(original_aa[which], which, '') newprofile = serialize_profile(aa[which], which, '') Regards, Christian Boltz -- 'blah blahb lah' ... I have no idea where it's coming from, grepping rug and zmd sources does not have any matches. [from https://bugzilla.novell.com/show_bug.cgi?id=157405]
signature.asc
Description: This is a digitally signed message part.
-- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor