Subject: bin/12727: files in /var/backups are not unique (based on path)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <windsor@warthog.com>
List: netbsd-bugs
Date: 04/23/2001 17:36:44
>Number:         12727
>Category:       bin
>Synopsis:       files in /var/backups are not unique (based on path)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 23 15:39:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Rob Windsor <windsor@warthog.com>
>Release:        irrelevant
>Organization:
Nose Pickers Anonymous
>Environment:
irrelevant
System: NetBSD apollo 1.5U NetBSD 1.5U (SUN4M_CURRENT) #0: Fri Apr 20 23:48:35 CDT 2001 rwroot@apollo:/usr/src/sys/arch/sparc/compile/SUN4M_CURRENT sparc
Architecture:	sparc
Machine:	sparc
>Description:
	Files archived in /var/backups are not unique, but merely based
	upon filename.  I highly recommend that we avoid name collisions
	between files (i.e. /etc/bootparams and /etc/rc.d/bootparams)
	by encoding the path in the filename in /var/backups.

>How-To-Repeat:
	add /etc/bootparams and /etc/rc.d/bootparams to /etc/changelist
	and watch the fun.
>Fix:
	I fixed this problem by a simple 's,/,_,g' sed line.  Here's
	my patch to src/etc/security.

--- security.FCS	Mon Apr 23 17:29:38 2001
+++ security	Mon Apr 23 17:30:48 2001
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: security,v 1.51 2001/03/15 02:23:47 hubertf Exp $
+#	$NetBSD$
 #	from: @(#)security	8.1 (Berkeley) 6/9/93
 #
 
@@ -677,8 +677,9 @@
 
 if [ -n "$CHANGELIST" ]; then
 	for file in `egrep -hv "^#|$MP" $CHANGELIST`; do
-		CUR=$backup_dir/${file##*/}.current
-		BACK=$backup_dir/${file##*/}.backup
+		WASH=`echo $file | sed -e 's,/,_,g'`
+		CUR=$backup_dir/$WASH.current
+		BACK=$backup_dir/$WASH.backup
 		if [ -f $file ]; then
 			if [ -f $CUR ] ; then
 				diff $CUR $file > $OUTPUT

>Release-Note:
>Audit-Trail:
>Unformatted: