for pid in sorted(profile_changes.keys()): set_process(pid, profile_changes[pid])
collapse_log()
So it seems first the full log is read, then handle_children processes the log entries, set_process() changes the profiles of running processes (if they have null-XY subprofiles) and finally collapse_log() is called.
handle_children() loops over all log events, so it should be easy to change it to get one call per log entry.
handle_children() changes profile_changes at various places, so integrating set_process() causes some work. The solution is probably to change all "profile_changes[pid] = ..." to call a helper function that
- checks if profile_changes[pid] is already set and, if it is, is identical to the new value
- if there is a real change, call set_process() for that pid
- and of course include profile_changes[pid] = ...
After that, integrating collapse_log() shouldn't be too hard.
With this change, only events that cause questions for profile changes will be kept in memory.
I just checked the code - see aa.py do_logprof_pass(). Shortened quote (comments removed):
log_reader = apparmor. logparser. ReadLog( pid, filename, existing_profiles, profile_dir, log) read_log( logmark)
log = log_reader.
for root in log:
handle_ children( '', '', root)
for pid in sorted( profile_ changes. keys()) :
set_process( pid, profile_ changes[ pid])
collapse_log()
So it seems first the full log is read, then handle_children processes the log entries, set_process() changes the profiles of running processes (if they have null-XY subprofiles) and finally collapse_log() is called.
handle_children() loops over all log events, so it should be easy to change it to get one call per log entry.
handle_children() changes profile_changes at various places, so integrating set_process() causes some work. The solution is probably to change all "profile_ changes[ pid] = ..." to call a helper function that changes[ pid] is already set and, if it is, is identical to the new value changes[ pid] = ...
- checks if profile_
- if there is a real change, call set_process() for that pid
- and of course include profile_
After that, integrating collapse_log() shouldn't be too hard.
With this change, only events that cause questions for profile changes will be kept in memory.