* Fabian Pietsch <[EMAIL PROTECTED]> (Sun, 31 Dec 2006 17:48:01 +0100):
>
> Package: acct
> Version: 6.4~pre1-3
>
> acct's cron.monthly script seems to be severely broken since -3.
>
> What seems to be a good-faith attempt to handle switching between
> compressed and uncompressed rotated logfiles gracefully, turns out to be
> affected by the following defects:
>
[...]
>
> The previous (-1) version's only defect, on the other hand, seems to be
> that it unconditionally uses a possibly-existing uncompressed rotated
> logfile in addition to the previously detected existing
> uncompressed-or-compressed one, and there, too, only for `ac', not for
> `last'. It could have been fixed simply be dropping the superflous
> '-f /var/log/wtmp.1'.
>
[...]
Sorry, forgot to attach both scripts for public review.
They live in /etc/cron.monthly/acct after installation
(if that wasn't obvious).
--
Fabian "zzz" Pietsch - http://zzz.arara.de/
#!/bin/sh
#
# cron script to perform monthly login accounting.
#
# Written by Ian A. Murdock <[EMAIL PROTECTED]>
# Modified by Dirk Eddelbuettel <[EMAIL PROTECTED]>
# Modified by Tero Tilus <[EMAIL PROTECTED]>
# patch adopted by Christian Perrier <[EMAIL PROTECTED]> for #187538
LOGROTATE="/etc/cron.daily/logrotate"
if [ -x /usr/sbin/accton ]
then
echo "Login accounting for the month ended `date`:" >
/var/log/wtmp.report
echo >> /var/log/wtmp.report
# The logrotate script happens to run before this one, effectively
# swallowing all information out of wtmp before we can use it.
# Hence, we need to use the previous file. Bad hack.
# Too bad we never heard from the logrotate maintainer about this ...
# edd 18 May 2002 make sure wtmp.1 exists
if [ -f "${LOGROTATE}" ] && [ -x /usr/sbin/logrotate ]
then
if [ -f /var/log/wtmp.1 ]
then
WTMP="/var/log/wtmp.1"
elif [ -f /var/log/wtmp.1.gz ]
then
WTMP_WAS_GZIPPED="1"
WTMP="`tempfile`"
gunzip -c /var/log/wtmp.1.gz > "${WTMP}"
fi
ac -f "${WTMP}" -f /var/log/wtmp.1 -p | sort -nr -k2 >>
/var/log/wtmp.report
echo >> /var/log/wtmp.report
last -f "${WTMP}" >> /var/log/wtmp.report
if [ -n "${WTMP_WAS_GZIPPED}" ]
then
# remove temporary file
rm -f "${WTMP}"
fi
else
ac -p | sort -nr -k2 >> /var/log/wtmp.report
echo >> /var/log/wtmp.report
last >> /var/log/wtmp.report
fi
fi
#!/bin/sh
#
# cron script to perform monthly login accounting.
#
# Written by Ian A. Murdock <[EMAIL PROTECTED]>
# Modified by Dirk Eddelbuettel <[EMAIL PROTECTED]>
# Modified by Tero Tilus <[EMAIL PROTECTED]>
# patch adopted by Christian Perrier <[EMAIL PROTECTED]> for #187538
LOGROTATE="/etc/cron.daily/logrotate"
if [ -x /usr/sbin/accton ]
then
echo "Login accounting for the month ended `date`:" >
/var/log/wtmp.report
echo >> /var/log/wtmp.report
# The logrotate script happens to run before this one, effectively
# swallowing all information out of wtmp before we can use it.
# Hence, we need to use the previous file. Bad hack.
# Too bad we never heard from the logrotate maintainer about this ...
# edd 18 May 2002 make sure wtmp.1 exists
if [ -f "${LOGROTATE}" ] && [ -x /usr/sbin/logrotate ]
then
if [ -f /var/log/wtmp.1 ]
then
LOGFILE="/var/log/wtmp.1"
fi
if [ -f /var/log/wtmp.1.gz ]
then
LOGFILE2="`tempfile`"
fi
if [ -n "${LOGFILE}" ] && [ -n "${LOGFILE2}" ]
then
ac -f "${LOGFILE2}" -f "${LOGFILE}" -p | sort -nr -k2
>> /var/log/wtmp.report
echo >> /var/log/wtmp.report
last -f "${LOGFILE2}" >> /var/log/wtmp.report
elif [ -n "${LOGFILE}" ] && [ -z "${LOGFILE2}" ]
then
ac -f "${LOGFILE}" -p | sort -nr -k2 >>
/var/log/wtmp.report
echo >> /var/log/wtmp.report
last -f "${LOGFILE}" >> /var/log/wtmp.report
fi
rm -f "${LOGFILE2}"
else
ac -p | sort -nr -k2 >> /var/log/wtmp.report
echo >> /var/log/wtmp.report
last >> /var/log/wtmp.report
fi
fi