From joshua@leather.shallow.net  Sat Jan 11 05:59:28 2003
Return-Path: <joshua@leather.shallow.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 61B9E37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 11 Jan 2003 05:59:28 -0800 (PST)
Received: from leather.shallow.net (c16486.smelb1.vic.optusnet.com.au [210.49.224.105])
	by mx1.FreeBSD.org (Postfix) with ESMTP id BF8E943EB2
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 11 Jan 2003 05:59:27 -0800 (PST)
	(envelope-from joshua@leather.shallow.net)
Received: by leather.shallow.net (Postfix, from userid 1001)
	id 1E856230A; Sun, 12 Jan 2003 00:59:04 +1100 (EST)
Message-Id: <20030111135904.1E856230A@leather.shallow.net>
Date: Sun, 12 Jan 2003 00:59:04 +1100 (EST)
From: Joshua Goodall <joshua@roughtrade.net>
Reply-To: Joshua Goodall <joshua@roughtrade.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: newsyslog's archival path option doesn't honour -n
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         46974
>Category:       bin
>Synopsis:       newsyslog's archival path option doesn't honour -n
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gad
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 11 06:00:09 PST 2003
>Closed-Date:    Sun Apr 27 16:51:37 PDT 2003
>Last-Modified:  Sun Apr 27 16:51:37 PDT 2003
>Originator:     Joshua Goodall
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD leather.shallow.net 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Sat Jan 4 19:42:54 EST 2003 joshua@leather.shallow.net:/usr/obj/usr/src/sys/LEATHER i386
>Description:
newsyslog's -a option exists to archive logfiles to a directory. It creates
the path if it does not already exist.  The -n option is supposedly
a "dry run" option; however it fails to suppress the path creation.

>How-To-Repeat:

Execute (with a stock /etc/newsyslog.conf):
# newsyslog -nv -a foo

( the directory /var/log/foo now exists )

>Fix:

Index: newsyslog.c
===================================================================
RCS file: /cvs/src/usr.sbin/newsyslog/newsyslog.c,v
retrieving revision 1.49
diff -u -r1.49 newsyslog.c
--- newsyslog.c	21 Dec 2002 22:27:26 -0000	1.49
+++ newsyslog.c	11 Jan 2003 13:42:05 -0000
@@ -582,8 +582,12 @@
 		}
 
 		/* check if archive directory exists, if not, create it */
-		if (lstat(dirpart, &st))
-			createdir(dirpart);
+		if (lstat(dirpart, &st)) {
+			if (noaction)
+				printf("mkdir -p %s\n", dirpart);
+			else
+				createdir(dirpart);
+		}
 
 		/* get filename part of logfile */
 		if ((p = rindex(log, '/')) == NULL)

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->johan 
Responsible-Changed-By: johan 
Responsible-Changed-When: Mon Feb 3 12:47:20 PST 2003 
Responsible-Changed-Why:  
I will look at this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46974 
Responsible-Changed-From-To: johan->gad 
Responsible-Changed-By: johan 
Responsible-Changed-When: Sat Feb 22 03:03:24 PST 2003 
Responsible-Changed-Why:  
Over to gad who said he will take care of this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46974 
State-Changed-From-To: open->patched 
State-Changed-By: gad 
State-Changed-When: Sun Feb 23 18:45:05 PST 2003 
State-Changed-Why:  
I have committed a fix for this to -current, although it's different than 
the given in the PR.  I thought it would be better for createdir to write 
out the "noaction" message, so it could write a message for *each* directory 
that's being made.  Say someone requests '-a /var/loq/archive-d', then 
they'd expect a mkdir message for the "archive-d" part, but they would 
also like to know that they gave the typo of 'loq' when they meant 'log'. 

Thanks for spotting this.  I'll MFC this fix to 4.x before closing the PR. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=46974 
State-Changed-From-To: patched->closed 
State-Changed-By: gad 
State-Changed-When: Sun Apr 27 16:50:51 PDT 2003 
State-Changed-Why:  
The fix for this has been MFC-ed into freebsd-stable. 

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