Skip to content

aa-notify: don't crash if the logfile is not present due to rotation

John Johansen requested to merge jjohansen/apparmor:aa-notify into master

If aa-notify races file rotation it may crash with a trace back to the log file being removed before the new one is moved into place.

Traceback (most recent call last):
   File "/usr/sbin/aa-notify", line 570, in <module>
     main()
   File "/usr/sbin/aa-notify", line 533, in main
      for message in notify_about_new_entries(logfile, args.wait):
   File "/usr/sbin/aa-notify", line 145, in notify_about_new_entries
     for event in follow_apparmor_events(logfile, wait):
   File "/usr/sbin/aa-notify", line 236, in follow_apparmor_events
     if os.stat(logfile).st_ino != log_inode:
FileNotFoundError: [Errno 2] No such file or directory: '/var/log/audit/audit.log'

If we hit this situation sleep and then retry opening the logfile.

Fixes: #130 (closed) MR: Signed-off-by: John Johansen john.johansen@canonical.com

Merge request reports