From olli@grabthar.secnetix.de  Thu May 30 20:34:08 2013
Return-Path: <olli@grabthar.secnetix.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id 32F062F6
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 30 May 2013 20:34:08 +0000 (UTC)
	(envelope-from olli@grabthar.secnetix.de)
Received: from grabthar.secnetix.de (grabthar.secnetix.de [212.17.241.225])
	by mx1.freebsd.org (Postfix) with ESMTP id BC280634
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 30 May 2013 20:34:07 +0000 (UTC)
Received: from grabthar.secnetix.de (localhost [127.0.0.1])
	by grabthar.secnetix.de (8.14.5/8.14.5) with ESMTP id r4UKY0BX028155;
	Thu, 30 May 2013 22:34:00 +0200 (CEST)
	(envelope-from oliver.fromme@secnetix.de)
Received: (from olli@localhost)
	by grabthar.secnetix.de (8.14.5/8.14.5/Submit) id r4UKY0Sk028154;
	Thu, 30 May 2013 22:34:00 +0200 (CEST)
	(envelope-from olli)
Message-Id: <201305302034.r4UKY0Sk028154@grabthar.secnetix.de>
Date: Thu, 30 May 2013 22:34:00 +0200 (CEST)
From: Oliver Fromme <olli@secnetix.de>
Reply-To: Oliver Fromme <olli@secnetix.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Oliver Fromme <olli@secnetix.de>
Subject: [patch] Fix bug with newsyslog -t
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         179122
>Category:       bin
>Synopsis:       [patch] newsyslog(8): Fix bug with newsyslog -t
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    markj
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 30 20:40:01 UTC 2013
>Closed-Date:    Sat Jun 08 15:55:57 UTC 2013
>Last-Modified:  Sat Jun 08 15:55:57 UTC 2013
>Originator:     Oliver Fromme
>Release:        FreeBSD 9.1-STABLE-20130529 amd64
>Organization:
secnetix GmbH & Co. KG
>Environment:

The problem was found on stable/9 as of 2013-05-29,
but it probably also exists on head and stable/8.

>Description:

The latest commits to newsyslog.c seem to have introduced
a problem with the -t option:  The wrong file name is used
with the fstatat() call when checking for the mtime.
This becomes especially apparent when thr -a option is
also used, because the file does not exist in the archive
directory, so newsyslog prints error messages.  See below.

>How-To-Repeat:

Change the newsyslog entry in /etc/crontab to use both
-t and -a, for example:

0    *    *    *    *    root    newsyslog -a OLD -t DEFAULT

Soon you will get output like the following mailed to you
by cron:

newsyslog: Cannot stat '/var/log/OLD/maillog': No such file or directory
newsyslog: Cannot stat '/var/log/OLD/messages': No such file or directory

>Fix:

--- usr.sbin/newsyslog/newsyslog.c.orig	2013-05-11 03:01:44.000000000 +0200
+++ usr.sbin/newsyslog/newsyslog.c	2013-05-30 15:55:19.000000000 +0200
@@ -2313,7 +2313,7 @@
 		if (validate_old_timelog(dp, logfname, &tm) == 0)
 			continue;
 
-		if (fstatat(dir_fd, logfname, &sb, 0) == -1) {
+		if (fstatat(dir_fd, dp->d_name, &sb, 0) == -1) {
 			warn("Cannot stat '%s'", file);
 			continue;
 		}
>Release-Note:
>Audit-Trail:

From: Mark Johnston <markj@freebsd.org>
To: Oliver Fromme <olli@secnetix.de>
Cc: bug-followup@freebsd.org
Subject: Re: bin/179122: [patch] Fix bug with newsyslog -t
Date: Thu, 30 May 2013 17:16:35 -0400

 > newsyslog: Cannot stat '/var/log/OLD/maillog': No such file or directory
 > newsyslog: Cannot stat '/var/log/OLD/messages': No such file or directory
 
 Hi Oliver,
 
 Thanks for reporting this. I've done some testing and the patch looks
 correct. Have you configured the log file in question to be rotated once
 every hour? If not, then newsyslog -t wouldn't have been working
 properly before either.
 
 Thanks,
 -Mark

From: Oliver Fromme <olli@grabthar.secnetix.de>
To: markj@freebsd.org (Mark Johnston)
Cc: olli@secnetix.de (Oliver Fromme), bug-followup@freebsd.org
Subject: Re: bin/179122: [patch] Fix bug with newsyslog -t
Date: Fri, 31 May 2013 10:40:32 +0200 (CEST)

 Hi Mark,
 
  > Thanks for reporting this. I've done some testing and the patch looks
  > correct. Have you configured the log file in question to be rotated once
  > every hour? If not, then newsyslog -t wouldn't have been working
  > properly before either.
 
 No, this is with the default newsyslog.conf of a fresh
 installation.
 
 I've been using -a and -t together on a different machine
 with an older version of stable/9 (about half a year old),
 and I never got any such error messages from newsyslog
 there.  However, I did not verify that the rotation
 really worked correctly ...  I assumed it did.  I only
 started to look more closely now that I got those error
 messages with the recent version of stable/9.
 
 Thanks for looking at this issue!
 
 Best regards
    Oliver
 
 
 -- 
 Oliver Fromme,  secnetix GmbH & Co. KG,  Marktplatz 29, 85567 Grafing
 Handelsregister:  Amtsgericht Muenchen, HRA 74606, Geschftsfuehrung:
 secnetix Verwaltungsgesellsch. mbH, Handelsreg.: Amtsgericht Mnchen,
 HRB 125758, Geschftsfhrer:  Maik Bachmann,  Olaf Erb,  Ralf Gebhart
 
 FreeBSD-Dienstleistungen/-Produkte + mehr: http://www.secnetix.de/bsd
 
 "Above all, they contribute to the genetic diversity in the
 operating system pool.  Which is a good thing."
   -- Ruben van Staveren, on the question which BSD OS is the best one.

From: Mark Johnston <markj@freebsd.org>
To: Oliver Fromme <olli@grabthar.secnetix.de>
Cc: Oliver Fromme <olli@secnetix.de>, bug-followup@freebsd.org
Subject: Re: bin/179122: [patch] Fix bug with newsyslog -t
Date: Fri, 31 May 2013 11:06:29 -0400

 On Fri, May 31, 2013 at 10:40:32AM +0200, Oliver Fromme wrote:
 > Hi Mark,
 > 
 >  > Thanks for reporting this. I've done some testing and the patch looks
 >  > correct. Have you configured the log file in question to be rotated once
 >  > every hour? If not, then newsyslog -t wouldn't have been working
 >  > properly before either.
 > 
 > No, this is with the default newsyslog.conf of a fresh
 > installation.
 > 
 > I've been using -a and -t together on a different machine
 > with an older version of stable/9 (about half a year old),
 > and I never got any such error messages from newsyslog
 > there.  However, I did not verify that the rotation
 > really worked correctly ...  I assumed it did.  I only
 > started to look more closely now that I got those error
 > messages with the recent version of stable/9.
 
 newsyslog -t has never worked properly for rotating logfiles based on
 mtimes; my fix tried to address that, but as you noticed, there is a
 problem. :)
 
 Aside from the error messages, the behaviour of newsyslog in your case
 will be the same as before. I will commit your patch later today.
 
 Thanks again,
 -Mark

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/179122: commit references a PR
Date: Sun,  2 Jun 2013 01:10:56 +0000 (UTC)

 Author: markj
 Date: Sun Jun  2 01:10:49 2013
 New Revision: 251240
 URL: http://svnweb.freebsd.org/changeset/base/251240
 
 Log:
   We want to stat the archived log file rather than the logfile itself.
   
   PR:		bin/179122
   Submitted by:	Oliver Fromme <olli@secnetix.de>
   MFC after:	3 days
 
 Modified:
   head/usr.sbin/newsyslog/newsyslog.c
 
 Modified: head/usr.sbin/newsyslog/newsyslog.c
 ==============================================================================
 --- head/usr.sbin/newsyslog/newsyslog.c	Sun Jun  2 01:07:38 2013	(r251239)
 +++ head/usr.sbin/newsyslog/newsyslog.c	Sun Jun  2 01:10:49 2013	(r251240)
 @@ -2326,7 +2326,7 @@ mtime_old_timelog(const char *file)
  		if (validate_old_timelog(dir_fd, dp, logfname, &tm) == 0)
  			continue;
  
 -		if (fstatat(dir_fd, logfname, &sb, AT_SYMLINK_NOFOLLOW) == -1) {
 +		if (fstatat(dir_fd, dp->d_name, &sb, AT_SYMLINK_NOFOLLOW) == -1) {
  			warn("Cannot stat '%s'", file);
  			continue;
  		}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: markj 
State-Changed-When: Sun Jun 2 15:38:05 UTC 2013 
State-Changed-Why:  
This is fixed by r251240. 


Responsible-Changed-From-To: freebsd-bugs->markj 
Responsible-Changed-By: markj 
Responsible-Changed-When: Sun Jun 2 15:38:05 UTC 2013 
Responsible-Changed-Why:  
This is fixed by r251240. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=179122 
State-Changed-From-To: patched->closed 
State-Changed-By: markj 
State-Changed-When: Sat Jun 8 15:55:55 UTC 2013 
State-Changed-Why:  
The fix has been merged to STABLE-8 and 9 in r251533 and r251532. Thanks 
for the report! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=179122 
>Unformatted:
