[apparmor] [patch] Fix save_profiles() for YaST
Christian Boltz
apparmor at cboltz.de
Wed Oct 11 20:16:46 UTC 2017
Hello,
YaST has two issues in the "save changed profiles" dialog:
- when using "save selected", the list of profiles doesn't get updated.
Update q.options inside the loop to fix this.
- the list of profiles is displayed as "["/usr/bin/foo", true]" instead
of just "/usr/bin/foo". Use changed.keys() instead of changed to fix
this. (text-mode aa-logprof doesn't change, it always displayed
"/usr/bin/foo" and continues to do so.)
References: https://bugzilla.opensuse.org/show_bug.cgi?id=1062667 part a)
I propose this patch for trunk and 2.11.
Note that 2.11 needs a slightly different patch (whitespace diff).
I have attached both variants.
[ 04-refresh-profile-list-on-save-selected.diff (for trunk) ]
--- utils/apparmor/aa.py 2017-10-11 21:19:17.237759879 +0200
+++ utils/apparmor/aa.py 2017-10-11 21:20:00.789641479 +0200
@@ -1820,13 +1820,15 @@ def save_profiles():
q.explanation = _('The following local profiles were changed. Would you like to save them?')
q.functions = ['CMD_SAVE_CHANGES', 'CMD_SAVE_SELECTED', 'CMD_VIEW_CHANGES', 'CMD_VIEW_CHANGES_CLEAN', 'CMD_ABORT']
q.default = 'CMD_VIEW_CHANGES'
- q.options = changed
q.selected = 0
ans = ''
arg = None
while ans != 'CMD_SAVE_CHANGES':
if not changed:
return
+
+ q.options = sorted(changed.keys())
+
ans, arg = q.promptUser()
if ans == 'CMD_SAVE_SELECTED':
profile_name = list(changed.keys())[arg]
[ 04-refresh-profile-list-on-save-selected.diff-2.11 (for 2.11 branch) ]
=== modified file 'utils/apparmor/aa.py'
--- utils/apparmor/aa.py 2017-08-04 20:27:16 +0000
+++ utils/apparmor/aa.py 2017-10-11 18:59:53 +0000
@@ -1959,13 +1959,15 @@
q.explanation = _('The following local profiles were changed. Would you like to save them?')
q.functions = ['CMD_SAVE_CHANGES', 'CMD_SAVE_SELECTED', 'CMD_VIEW_CHANGES', 'CMD_VIEW_CHANGES_CLEAN', 'CMD_ABORT']
q.default = 'CMD_VIEW_CHANGES'
- q.options = changed
q.selected = 0
ans = ''
arg = None
while ans != 'CMD_SAVE_CHANGES':
if not changed:
return
+
+ q.options = sorted(changed.keys())
+
ans, arg = q.promptUser()
if ans == 'CMD_SAVE_SELECTED':
profile_name = list(changed.keys())[arg]
Regards,
Christian Boltz
--
> got a patch?
-ENOTMYJOB
[> Markus Rueckert and Bernhard Walle in opensuse-packaging]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20171011/5db3f6a0/attachment.sig>
More information about the AppArmor
mailing list