[Bug 267464] periodic 310.accounting enables accounting even if it is disabled in rc.conf

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 17 Nov 2022 18:03:34 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267464

John Grafton <john.grafton@runbox.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.grafton@runbox.com

--- Comment #2 from John Grafton <john.grafton@runbox.com> ---
I was able to replicate this bug on my system.  I think a simple fix is to
check if the accounting system process is running in the periodic script. If
not, exit the periodic script indicating the service is not running instead of
attempting to rotate the logs.  onerotate_log turns accounting back on
regardless of what accounting_enable is set to.

I tested this patch on my local system and the periodic log rotate exits and
doesn't restart the accounting service if the [accounting] process is not
running.

diff --git a/usr.sbin/periodic/etc/daily/310.accounting
b/usr.sbin/periodic/etc/daily/310.accounting
index b0dd786447eb..6a47690a0a6a 100755
--- a/usr.sbin/periodic/etc/daily/310.accounting
+++ b/usr.sbin/periodic/etc/daily/310.accounting
@@ -18,6 +18,10 @@ case "$daily_accounting_enable" in
            echo '$daily_accounting_enable is set but /var/account/acct' \
                "doesn't exist"
            rc=2
+       elif ! pgrep -qS accounting
+       then
+           echo 'accounting service is not active'
+           rc=2
        elif [ -z "$daily_accounting_save" ]
        then
            echo '$daily_accounting_enable is set but ' \

-- 
You are receiving this mail because:
You are the assignee for the bug.