Fix aa-logprof "add hat" endless loop

This turned out to be a simple case of misinterpreting the promptUser()
result - it returns the answer and the selected option, and
"surprisingly" something like
    ('CMD_ADDHAT', 0)
never matched
    'CMD_ADDHAT'
;-)

I also noticed that the new hat doesn't get initialized as
profile_storage(), and that the changed profile doesn't get marked as
changed. This is also fixed by this patch.


References: https://bugs.launchpad.net/apparmor/+bug/1538306


Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9
This commit is contained in:
Christian Boltz 2016-08-15 22:06:47 +02:00
parent 4ad98a8302
commit 791d40aa9d

View file

@ -1095,7 +1095,7 @@ def handle_children(profile, hat, root):
seen_events += 1
ans = q.promptUser()
ans = q.promptUser()[0]
if ans == 'CMD_FINISHED':
save_profiles()
@ -1105,7 +1105,9 @@ def handle_children(profile, hat, root):
if ans == 'CMD_ADDHAT':
hat = uhat
aa[profile][hat] = profile_storage(profile, hat, 'handle_children addhat')
aa[profile][hat]['flags'] = aa[profile][profile]['flags']
changed[profile] = True
elif ans == 'CMD_USEDEFAULT':
hat = default_hat
elif ans == 'CMD_DENY':