From owner-freebsd-bugs Mon Nov 19 12:50: 7 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 8774937B417 for ; Mon, 19 Nov 2001 12:50:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id fAJKo1983431; Mon, 19 Nov 2001 12:50:01 -0800 (PST) (envelope-from gnats) Received: from bsd.chem.msu.ru (bsd.chem.msu.ru [195.208.208.23]) by hub.freebsd.org (Postfix) with ESMTP id 5430237B416 for ; Mon, 19 Nov 2001 12:41:02 -0800 (PST) Received: (from yar@localhost) by bsd.chem.msu.ru (8.11.6/8.11.4) id fAJKexd30371; Mon, 19 Nov 2001 23:40:59 +0300 (MSK) (envelope-from yar) Message-Id: <200111192040.fAJKexd30371@bsd.chem.msu.ru> Date: Mon, 19 Nov 2001 23:40:59 +0300 (MSK) From: Yar Tikhiy To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: conf/32113: 200.accounting doesn't match newsyslog.conf Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 32113 >Category: conf >Synopsis: 200.accounting doesn't match newsyslog.conf >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Nov 19 12:50:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: Yar Tikhiy >Release: FreeBSD 4.4-STABLE i386 >Organization: Moscow State University >Environment: System: FreeBSD bsd.chem.msu.ru 4.4-STABLE FreeBSD 4.4-STABLE #1: Mon Oct 29 18:33:46 MSK 2001 yar@bsd.chem.msu.ru:/usr/src/sys/compile/BSD i386 >Description: Currently, the out-of-box /etc/periodic/monthly/200.accounting assumes that /var/log/wtmp.0 is uncompressed while the out-of-box newsyslog.conf tells newsyslog(8) to compress the rotated file with gzip(1). Consequently, the monthly accounting doesn't work. Another problem is that I cannot see either easy for an average user/admin or documented way to do weekly or daily wtmp rotation and accounting. Actually, to do that one should update *both* day and time in /etc/newsyslog.conf so wtmp gets rotated before the accounting run, move the script to the corresponding directory in /etc/periodic, and rename possible monthly_* configuration variables both in the script and in /etc/defaults/periodic.conf... >How-To-Repeat: See the email from a "periodic monthly" run. >Fix: On the one hand, the "Z" flag may be removed from the wtmp line in /etc/newsyslog.conf. However, a typical wtmp's compression ratio is too high to leave the file uncompressed. So, OTOH, 200.accounting may be modified as follows: --- 200.accounting.orig Tue Sep 26 04:04:27 2000 +++ 200.accounting Mon Nov 19 23:05:48 2001 @@ -14,18 +14,29 @@ case "$monthly_accounting_enable" in [Yy][Ee][Ss]) W=/var/log/wtmp + rc=0 + remove=NO if [ ! -f $W.0 ] then - echo '$monthly_accounting_enable is set but' \ - "$W.0 doesn't exist" - rc=2 - else + if [ -f $W.0.gz ] + then + remove=YES + zcat $W.0.gz > $W.0 || rc=1 + else + echo '$monthly_accounting_enable is set but' \ + "$W.0 doesn't exist" + rc=2 + fi + fi + if [ $rc -eq 0 ] + then echo "" echo "Doing login accounting:" rc=$(ac -p -w $W.0 | sort -nr +1 | tee /dev/stderr | wc -l) [ $rc -gt 0 ] && rc=1 - fi;; + fi + [ $remove = YES ] && rm -f $W.0;; *) rc=0;; esac >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message