python aa-logprof: saving remaining profile crashes after "save selected profile"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
AppArmor |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
(bzr trunk from today)
When first using "save selected profile" and later using "save changes", aa-logprof crashes.
It looks like it removes the already written profile from the list of modified profiles only partially, and then tries to write it again (but fails because at least one part is already missing).
The following screen log shows what happens - I used "save selected profiles" twice before using "save changes".
# python3 aa-logprof
[...]
= Changed Local Profiles =
The following local profiles were changed. Would you like to save them?
[1 - /usr/lib/
2 - /sbin/dhclient
3 - /usr/bin/boomaga
(S)ave Changes / Save Selec(t)ed Profile / [(V)iew Changes] / View Changes b/w (C)lean profiles / Abo(r)t
Aktualisiertes Profil für /usr/lib/
= Changed Local Profiles =
The following local profiles were changed. Would you like to save them?
[1 - /sbin/dhclient]
2 - /usr/bin/boomaga
(S)ave Changes / Save Selec(t)ed Profile / [(V)iew Changes] / View Changes b/w (C)lean profiles / Abo(r)t
= Changed Local Profiles =
The following local profiles were changed. Would you like to save them?
[1 - /sbin/dhclient]
2 - /usr/bin/boomaga
(S)ave Changes / Save Selec(t)ed Profile / [(V)iew Changes] / View Changes b/w (C)lean profiles / Abo(r)t
Aktualisiertes Profil für /sbin/dhclient wird geschrieben.
= Changed Local Profiles =
The following local profiles were changed. Would you like to save them?
[1 - /usr/bin/boomaga]
(S)ave Changes / Save Selec(t)ed Profile / [(V)iew Changes] / View Changes b/w (C)lean profiles / Abo(r)t
= Changed Local Profiles =
The following local profiles were changed. Would you like to save them?
[1 - /usr/bin/boomaga]
(S)ave Changes / Save Selec(t)ed Profile / [(V)iew Changes] / View Changes b/w (C)lean profiles / Abo(r)t
Aktualisiertes Profil für /sbin/dhclient wird geschrieben.
Traceback (most recent call last):
File "aa-logprof", line 52, in <module>
apparmor.
File "/home/
save_profiles()
File "/home/
write_
File "/home/
write_
File "/home/
changed.
KeyError: '/sbin/dhclient'
Changed in apparmor: | |
milestone: | none → 2.9.0 |
Note: aa.py has (line 2360):
if ans == 'CMD_SAVE_ SELECTED' :
profile_ name = list(changed. keys()) [arg]
write_ profile_ ui_feedback( profile_ name)
reload_ base(profile_ name)
# changed. pop(profile_ name)
# q['options' ] = changed
"changed.pop" was commented in r0.1.70:
if ans == 'CMD_SAVE_ SELECTED' :
profile_ name = list(changed. keys()) [arg]
write_profile_ ui_feedback( profile_ name)
reload_ base(profile_ name) pop(profile_ name) pop(profile_ name)
#q['options' ] = changed
- changed.
+ #changed.
If I re-enable the "changed.pop" line, I get
KeyError: '/usr/bin/boomaga'
for this line, so just removing the # is not an option.
Even more interesting: I added some debugging code:
#changed. pop(profile_ name)
+ for tmp_prof_name in changed.keys():
+ print("*** changed.keys(): %s" % prof_name)
and it only prints the profiles that are not saved yet.
IIRC I used "save selected" and "save changes" in the past - could it be that python 3.4 introduced this issue? ("dictionary changed size during iteration" is also a new "feature" of this version...)