Skip to content

Commit

Permalink
310.accounting: Verify process accounting is active before log rotation.
Browse files Browse the repository at this point in the history
This corrects a bug in which the daily periodic script '310.accounting'
attempts to rotate logs via /etc/rc.d/accounting by calling
onerotate_logs function. The rotate logs function turns accounting back
on regardless of what acccounting_enable is set to in /etc/rc.conf. This
is due to checkyesno always returning YES since rotate logs is called
with the 'one' prefix.

In effect, accounting will always be turned back on once a day even if
it is disabled and stopped by hand. The fix was simple, just check if
accounting is before rotating logs and if it is, don't attempt the
rotate.

PR: 267464
Reviewed by: imp, hps (lgtm, not approval), Mina Galić
Pull Request: freebsd/freebsd-src#648
Differential Revision: https://reviews.freebsd.org/D37434
  • Loading branch information
jgrafton authored and bsdjhb committed Mar 29, 2023
2 parents caa6eb6 + 9ab40bc commit 8524383
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions usr.sbin/periodic/etc/daily/310.accounting
Expand Up @@ -18,6 +18,11 @@ case "$daily_accounting_enable" in
echo '$daily_accounting_enable is set but /var/account/acct' \
"doesn't exist"
rc=2
elif [ $(sysctl -n kern.acct_configured) -eq 0 ]
then
echo '$daily_accounting_enable is set but' \
'process accounting is not active'
rc=2
elif [ -z "$daily_accounting_save" ]
then
echo '$daily_accounting_enable is set but ' \
Expand Down

0 comments on commit 8524383

Please sign in to comment.