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

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 18 Nov 2022 01:39:41 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267464

--- Comment #3 from John Grafton <john.grafton@runbox.com> ---
Ignore the last patch, it's too hacky.  Grepping for the system process is
problematic due to the possibility of a process other than accounting returning
true for the grep.

This patch uses the kern.acct_configured sysctl to determine if accounting is
active instead.

diff --git a/usr.sbin/periodic/etc/daily/310.accounting
b/usr.sbin/periodic/etc/daily/310.accounting
index b0dd786447eb..8eeed16f0516 100755
--- a/usr.sbin/periodic/etc/daily/310.accounting
+++ b/usr.sbin/periodic/etc/daily/310.accounting
@@ -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 ' \

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