2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-04 00:05:14 +00:00

Merge branch 'utils_save_profiles' into 'master'

utils: fix and improve "save profiles"

See merge request apparmor/apparmor!10


Acked-by: Tyler Hicks <tyhicks@canonical.com> for master and 2.11
This commit is contained in:
Christian Boltz
2017-11-14 20:03:15 +00:00

View File

@@ -1823,16 +1823,20 @@ 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()
q.selected = arg # remember selection
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) q.selected = 0 # saving the selected profile removes it from the list, therefore reset selection
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 +1852,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, '')