Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Nov 2001 23:40:59 +0300 (MSK)
From:      Yar Tikhiy <yar@comp.chem.msu.su>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   conf/32113: 200.accounting doesn't match newsyslog.conf
Message-ID:  <200111192040.fAJKexd30371@bsd.chem.msu.ru>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200111192040.fAJKexd30371>