History log of /freebsd-current/contrib/openbsm/bin/auditdistd/trail.c
Revision Date Author Comments
# 4926792b 06-Dec-2018 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Consider the following situation:
The sender has .not_terminated file. It gets disconnected. The last trail
file is then terminated without adding new data (this can happen for example
when auditd is being stopped on the sender). After reconnect the .not_terminated
was not renamed on the receiver as it should.

We were already handling similar situation where the sender crashed and the
.not_terminated trail file was renamed to .crash_recovery. Extend this case to
handle the situation above.


# ac67acf0 03-Oct-2018 Pawel Jakub Dawidek <pjd@FreeBSD.org>

When we look for a new trail file there might be a race between find trail
file name and opening it. This race was not properly handled, because we were
copying new name before checking for openat(2) error and when we were trying
again we were starting with the next trail file. This could result in skipping
distribution of such a trail file.

Fix this problem by checking for ENOENT first (only for .not_terminated files)
and then updating (or not) tr_filename before restarting the search.

PR: 200139
Reported by: peter
Approved by: re (kib)