multilog prematurely rotates logs if one logdir is regular file
Martin Castillo <[email protected]> Thu, 11 Aug 2022 00:46:54 +0200
| Newsgroups | gmane.comp.djb.syslog |
|---|---|
| Message-ID | <[email protected]> |
Hi,
for my dnscache service I wanted multilog to create a status file.
I tried this, but initially forgot the '=' before the last argument:
#!/bin/sh
touch /run/log/dnscache.stats;
chown log:log /run/log/dnscache.stats;
exec chpst -u log multilog t s10000000 /var/log/dnscache \
'-*' '+*stats *' /run/log/dnscache.stats
As a result, multilog immediately quit and was restarted every second.
That's okay. But what I didn't expect was to have my logs in
/var/log/dnscache/ to be completely replaced by empty files!
Every time multilog was started, it rotated current (even when empty)
and deleted the oldest file. It's quite unfortunate that such a 'typo'
deletes your log files.
When I tried to reproduce this, I noticed that normally when multilog is
killed, it sets the execute bit on 'current'. But when it aborts in the
mentioned error case, it does not. When it starts, it rotates 'current'
if it's not executable by owner.
Maybe it should (1) check for an empty 'current' file and not rotate in
that case or (2) properly close (mark executable/ doing the equivalent
of c_quit()) those files in logdirs that are not related to the error.
Though these may not be the best fixes, as I'm not too familiar with the
code.
Martin Castillo