NetBSD Problem Report #40274

From taca@back-street.net  Fri Dec 26 02:13:19 2008
Return-Path: <taca@back-street.net>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 00FB963BC5B
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 26 Dec 2008 02:13:18 +0000 (UTC)
Message-Id: <20081226021313.7A4515DC45@www.back-street.net>
Date: Fri, 26 Dec 2008 11:13:13 +0900 (JST)
From: taca@back-street.net
Reply-To: taca@back-street.net
To: gnats-bugs@gnats.NetBSD.org
Subject: newsyslog(8)'s "P" flag stops rotating log files.
X-Send-Pr-Version: 3.95

>Number:         40274
>Category:       bin
>Synopsis:       newsyslog(8)'s "P" flag stops rotating log files.
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 26 02:15:00 +0000 2008
>Closed-Date:    Sat Dec 19 02:40:41 +0000 2015
>Last-Modified:  Sat Dec 19 02:40:41 +0000 2015
>Originator:     Takahiro Kambe
>Release:        NetBSD 5.0_BETA
>Organization:

>Environment:


System: NetBSD ns.back-street.net 5.0_BETA NetBSD 5.0_BETA (EPIA) #5: Sat Nov 29 22:27:13 JST 2008 taca@boy.a.back-street.net:/data/i386/obj5/sys/arch/i386/compile/EPIA i386
Architecture: i386
Machine: i386
>Description:
	When specifies "P" flags in /etc/newsyslog.conf, newsyslog(8) stops
	rotating log files.  (I've lost log files in several days.)

>How-To-Repeat:
	Here is I checked.

	# echo "/var/log/t 640 5 100 * ZPBC" >> /etc/newsyslog.conf
	# dd if=/dev/zero of=/var/log/t count=5000
	5000+0 records in
	5000+0 records out
	2560000 bytes transferred in 0.062 secs (41290322 bytes/sec)
	# ls -l /var/log/t*                       
	-rw-r--r--  1 root  wheel  2560000 Dec 26 11:07 /var/log/t
	# newsyslog 
	# ls -l /var/log/t*
	-rw-r-----  1 root  wheel        0 Dec 26 11:08 /var/log/t
	-rw-r--r--  1 root  wheel  2560000 Dec 26 11:07 /var/log/t.0
	# dd if=/dev/zero of=/var/log/t count=5000
	5000+0 records in
	5000+0 records out
	2560000 bytes transferred in 0.062 secs (41290322 bytes/sec)
	# newsyslog
	# ls -l /var/log/t*
	-rw-r-----  1 root  wheel        0 Dec 26 11:08 /var/log/t
	-rw-r--r--  1 root  wheel  2560000 Dec 26 11:07 /var/log/t.0

	Now, /var/log/t.1.gz should be exists but not.
>Fix:
	Unknown, just looking for codes.

>Release-Note:

>Audit-Trail:
From: Takahiro Kambe <taca@back-street.net>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/40274: newsyslog(8)'s "P" flag stops rotating log files.
Date: Fri, 26 Dec 2008 11:53:44 +0900 (JST)

 Oops, I sent to wrong address.

 In message <20081226021501.3EF4163BC6A@narn.NetBSD.org>
 	on Fri, 26 Dec 2008 02:15:01 +0000 (UTC),
 	taca@back-street.net wrote:
 > >Fix:
 > 	Unknown, just looking for codes.
 * Compress all old log files even if "P" flag is specigied
 * Compress old log files before log rotatation.

 Seems to work for me.

 Index: newsyslog.c
 ===================================================================
 RCS file: /cvs/src-5/usr.bin/newsyslog/newsyslog.c,v
 retrieving revision 1.1.1.1
 diff -u -r1.1.1.1 newsyslog.c
 --- newsyslog.c	8 Dec 2008 02:03:29 -0000	1.1.1.1
 +++ newsyslog.c	26 Dec 2008 02:26:23 -0000
 @@ -538,6 +538,25 @@
  		}
  	}

 +	/*
 +	 * If a historical log file isn't compressed, and 'z' has been
 +	 * specified, compress it.  (This is convenient, but is also needed
 +	 * if 'p' has been specified.)  It should be noted that gzip(1)
 +	 * preserves file ownership and file mode.
 +	 */
 +	if (ziptype) {
 +		for (i = 0; i < log->numhist; i++) {
 +			snprintf(file1, sizeof(file1), "%s.%d", log->logfile, i);
 +			if (lstat(file1, &st) != 0)
 +				continue;
 +			snprintf(file2, sizeof(file2), "%s%s", file1,
 +			    compress[ziptype].suffix);
 +			if (lstat(file2, &st) == 0)
 +				continue;
 +			log_compress(log, file1);
 +		}
 +	}
 +
  	/* Move down log files. */
  	for (i = log->numhist - 1; i > 0; i--) {
  		for (j = 0; j < (int)__arraycount(compress); j++) {
 @@ -565,25 +584,6 @@
  				err(EXIT_FAILURE, "%s", file2);
  	}

 -	/*
 -	 * If a historical log file isn't compressed, and 'z' has been
 -	 * specified, compress it.  (This is convenient, but is also needed
 -	 * if 'p' has been specified.)  It should be noted that gzip(1)
 -	 * preserves file ownership and file mode.
 -	 */
 -	if (ziptype) {
 -		for (i = (log->flags & CE_PLAIN0) != 0; i < log->numhist; i++) {
 -			snprintf(file1, sizeof(file1), "%s.%d", log->logfile, i);
 -			if (lstat(file1, &st) != 0)
 -				continue;
 -			snprintf(file2, sizeof(file2), "%s%s", file1,
 -			    compress[ziptype].suffix);
 -			if (lstat(file2, &st) == 0)
 -				continue;
 -			log_compress(log, file1);
 -		}
 -	}
 -
  	log_trimmed(log);

  	/* Create the historical log file if we're maintaining history. */


State-Changed-From-To: open->closed
State-Changed-By: christos@NetBSD.org
State-Changed-When: Sat, 20 Jun 2009 15:34:55 -0400
State-Changed-Why:
patch applied.


From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40274 CVS commit: src/usr.bin/newsyslog
Date: Sat, 20 Jun 2009 15:34:20 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Sat Jun 20 19:34:20 UTC 2009

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

 Log Message:
 PR/40274: Takahiro Kambe: "P" flag stops rotating files.


 To generate a diff of this commit:
 cvs rdiff -u -r1.57 -r1.58 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: Takahiro Kambe <taca@back-street.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/40274 (newsyslog(8)'s "P" flag stops rotating log files.)
Date: Sun, 28 Jun 2009 10:40:32 +0900 (JST)

 In message <20090620193457.F14F463C278@www.NetBSD.org>
 	on Sat, 20 Jun 2009 19:34:57 +0000 (UTC),
 	christos@NetBSD.org wrote:
 > Synopsis: newsyslog(8)'s "P" flag stops rotating log files.
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: christos@NetBSD.org
 > State-Changed-When: Sat, 20 Jun 2009 15:34:55 -0400
 > State-Changed-Why:
 > patch applied.
 Since this PR targeted to NetBSD 5.0, please pulled up it to
 netbsd-5 branch.

 Best regards.

 -- 
 Takahiro Kambe <taca@back-street.net>

State-Changed-From-To: closed->open
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Tue, 07 Jul 2009 04:21:03 +0000
State-Changed-Why:
pullups to -5 are requested.


State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 19 Dec 2015 02:40:41 +0000
State-Changed-Why:
nobody ever did -5 pullup and -5 is now EOL


>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.