Package: acct
Version: 6.5.5-2.1
Severity: normal
Tags: patch
Occasionally the accounting subsystem doesn not begin
writing to the new account file ('/var/log/accout/pacct')
after the savelog is done in '/etc/cron.daily/acct'.
I had observed this phenomena on Fedora systems and
recently saw it in Debian. One of the symptoms was that
new accounting records continued to be written to the
previous accounting file, which is now 'pacct.0', so the
cause may be the kernel having an open file handle.
Attached is a patch to keep restarting the acct service
until it is observed that the new accounting file increases
in size.
-- System Information:
Debian Release: stretch/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 3.16.7-ckt11-1-inter04-686-pae (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL
set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages acct depends on:
ii dpkg 1.18.1
ii install-info 5.2.0.dfsg.1-6
ii libc6 2.19-18
acct recommends no packages.
acct suggests no packages.
-- Configuration Files:
/etc/cron.daily/acct changed:
test -x /usr/sbin/accton || exit 0
if [ -f /etc/default/acct ]
then
. /etc/default/acct
else
ACCT_LOGGING="30"
fi
cd /var/log/account
savelog -g adm -m 0640 -u root -c "${ACCT_LOGGING}" /var/log/account/pacct >
/dev/null
ACCTSIZE=$(ls -l /var/log/account/pacct | awk '{print $5}')
while [ $ACCTSIZE -eq 0 ];do
invoke-rc.d acct restart > /dev/null
ACCTSIZE=$(ls -l /var/log/account/pacct | awk '{print $5}')
done
fi
exit 0
-- no debconf information
--- acct.cron.daily 2015-06-15 11:18:29.527749598 -0400
+++ acct.cron.daily.new 2015-06-15 11:17:31.364969569 -0400
@@ -15,7 +15,18 @@
savelog -g adm -m 0640 -u root -c "${ACCT_LOGGING}" /var/log/account/pacct > /dev/null
# Restart acct
-invoke-rc.d acct restart > /dev/null
+#
+# Kernel may have open file handle on the old pacct file
+# so keep stopping and starting acct until new records are
+# written to the new account file
+#
+#if systemctl --quiet is-active acct.service >/dev/null 2>&1; then
+ ACCTSIZE=$(ls -l /var/log/account/pacct | awk '{print $5}')
+ while [ $ACCTSIZE -eq 0 ];do
+ invoke-rc.d acct restart > /dev/null
+ ACCTSIZE=$(ls -l /var/log/account/pacct | awk '{print $5}')
+ done
+fi
# This is needed because accton.c returns errno
exit 0