2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-29 13:28:19 +00:00

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.
This commit is contained in:
Christian Boltz 2017-11-12 20:22:49 +01:00
parent 21bc71e576
commit fe1fb7caa3
No known key found for this signature in database
GPG Key ID: C6A682EA63C82F1C

View File

@ -1823,16 +1823,18 @@ def save_profiles():
if not changed: if not changed:
return return
q.options = sorted(changed.keys()) options = sorted(changed.keys())
q.options = options
ans, arg = q.promptUser() ans, arg = q.promptUser()
which = options[arg]
if ans == 'CMD_SAVE_SELECTED': if ans == 'CMD_SAVE_SELECTED':
profile_name = list(changed.keys())[arg] write_profile_ui_feedback(which)
write_profile_ui_feedback(profile_name) reload_base(which)
reload_base(profile_name)
elif ans == 'CMD_VIEW_CHANGES': elif ans == 'CMD_VIEW_CHANGES':
which = list(changed.keys())[arg]
oldprofile = None oldprofile = None
if aa[which][which].get('filename', False): if aa[which][which].get('filename', False):
oldprofile = aa[which][which]['filename'] oldprofile = aa[which][which]['filename']
@ -1848,7 +1850,6 @@ def save_profiles():
aaui.UI_Changes(oldprofile, newprofile, comments=True) aaui.UI_Changes(oldprofile, newprofile, comments=True)
elif ans == 'CMD_VIEW_CHANGES_CLEAN': elif ans == 'CMD_VIEW_CHANGES_CLEAN':
which = list(changed.keys())[arg]
oldprofile = serialize_profile(original_aa[which], which, '') oldprofile = serialize_profile(original_aa[which], which, '')
newprofile = serialize_profile(aa[which], which, '') newprofile = serialize_profile(aa[which], which, '')