NetBSD Problem Report #40635

From jukka+moray@salmi.ch  Sat Feb 14 00:59:47 2009
Return-Path: <jukka+moray@salmi.ch>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id DE9C963C17C
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 14 Feb 2009 00:59:46 +0000 (UTC)
Message-Id: <20090214005943.735C21A476@moray.salmi.ch>
Date: Sat, 14 Feb 2009 01:59:43 +0100 (CET)
From: Jukka Salmi <j+nbsd@salmi.ch>
Reply-To: Jukka Salmi <j+nbsd@salmi.ch>
To: gnats-bugs@gnats.NetBSD.org
Subject: newsyslog(8) overwrites logs too early if `p' flag is set (patch supplied)
X-Send-Pr-Version: 3.95

>Number:         40635
>Category:       bin
>Synopsis:       newsyslog(8) overwrites logs too early if `p' flag is set (patch supplied)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    dogcow
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 14 01:00:01 +0000 2009
>Closed-Date:    Tue Feb 17 02:59:05 +0000 2009
>Last-Modified:  Tue Feb 24 02:50:06 +0000 2009
>Originator:     Jukka Salmi
>Release:        NetBSD 5.99.5
>Organization:
>Environment:
System: NetBSD moray.salmi.ch 5.99.5 NetBSD 5.99.5 (GENERIC) #0: Fri Jan 2 17:20:03 CET 2009 root@moray.salmi.ch:/b/build/nbsd/c/i386/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
If in newsyslog.conf(5) the `p' flag ("don't compress the .0 file") is
specified, the logfile in question is not archived correctly:  only the current
version and the .0 file are kept, no matter what the `ngen' field is set to.
This means that one migh loose log files earlier than expected.
>How-To-Repeat:
$ cd /tmp
$ echo '/tmp/testlog 640 7 0 * PZ' >newsyslog.conf # keep 7 archived versions
$ touch testlog
$ ls -l testlog*
-rw-r--r--  1 jukka  wheel  0 Feb 14 01:55 testlog
$ newsyslog -f newsyslog.conf -rs
$ ls -l testlog*
-rw-r-----  1 jukka  jukka  69 Feb 14 01:55 testlog
-rw-r--r--  1 jukka  wheel  69 Feb 14 01:55 testlog.0
$ newsyslog -f newsyslog.conf -rs
$ ls -l testlog*
-rw-r-----  1 jukka  jukka   70 Feb 14 01:55 testlog
-rw-r-----  1 jukka  jukka  139 Feb 14 01:55 testlog.0

During the second newsyslog(8) run, `testlog.0' should have been moved and
compressed to `testlog.1.gz'.  This didn't happen and the file was overwritten
by the file `testlog'.

>Fix:
Seems to be just a typo:

Index: usr.bin/newsyslog/newsyslog.c
===================================================================
RCS file: /cvsroot/src/usr.bin/newsyslog/newsyslog.c,v
retrieving revision 1.56
diff -u -p -r1.56 newsyslog.c
--- usr.bin/newsyslog/newsyslog.c	29 Dec 2008 01:35:09 -0000	1.56
+++ usr.bin/newsyslog/newsyslog.c	14 Feb 2009 00:32:12 -0000
@@ -540,9 +540,9 @@ log_trim(struct conf_entry *log)
 	for (i = log->numhist - 1; i > 0; i--) {
 		for (j = 0; j < (int)__arraycount(compress); j++) {
 			snprintf(file1, sizeof(file1), "%s.%d%s", log->logfile,
-			    i - 1, compress[ziptype].suffix);
+			    i - 1, compress[j].suffix);
 			snprintf(file2, sizeof(file2), "%s.%d%s", log->logfile,
-			    i, compress[ziptype].suffix);
+			    i, compress[j].suffix);
 			k = lstat(file1, &st);
 			if (!k) break;
 		}

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: bin-bug-people->dogcow
Responsible-Changed-By: dogcow@NetBSD.org
Responsible-Changed-When: Tue, 17 Feb 2009 02:59:05 +0000
Responsible-Changed-Why:
my bug.


State-Changed-From-To: open->closed
State-Changed-By: dogcow@NetBSD.org
State-Changed-When: Tue, 17 Feb 2009 02:59:05 +0000
State-Changed-Why:
applied patch from PR, which is now in 1.57 of newsyslog.c.


From: Tom Spindler <dogcow@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40635 CVS commit: src/usr.bin/newsyslog
Date: Tue, 17 Feb 2009 02:56:43 +0000 (UTC)

 Module Name:	src
 Committed By:	dogcow
 Date:		Tue Feb 17 02:56:43 UTC 2009

 Modified Files:
 	src/usr.bin/newsyslog: newsyslog.c

 Log Message:
 Fix an embarrassing mistake regarding moving down log files. Reported by
 (and fix included in) PR bin/40635 from Jukka Salmi.


 To generate a diff of this commit:
 cvs rdiff -r1.56 -r1.57 src/usr.bin/newsyslog/newsyslog.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40635 CVS commit: [netbsd-5] src/usr.bin/newsyslog
Date: Tue, 24 Feb 2009 02:47:30 +0000 (UTC)

 Module Name:	src
 Committed By:	snj
 Date:		Tue Feb 24 02:47:30 UTC 2009

 Modified Files:
 	src/usr.bin/newsyslog [netbsd-5]: newsyslog.c

 Log Message:
 Pull up following revision(s) (requested by dogcow in ticket #473):
 	usr.bin/newsyslog/newsyslog.c: revision 1.57
 Fix an embarrassing mistake regarding moving down log files. Reported by
 (and fix included in) PR bin/40635 from Jukka Salmi.


 To generate a diff of this commit:
 cvs rdiff -r1.53 -r1.53.10.1 src/usr.bin/newsyslog/newsyslog.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.