From Arjan.deVet@adv.iae.nl  Sun Jul 16 13:11:10 2000
Return-Path: <Arjan.deVet@adv.iae.nl>
Received: from news.IAEhv.nl (news.IAE.nl [194.151.64.4])
	by hub.freebsd.org (Postfix) with ESMTP id CEA6E37B5AD
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 16 Jul 2000 13:11:08 -0700 (PDT)
	(envelope-from Arjan.deVet@adv.iae.nl)
Received: (from uucp@localhost)
	by news.IAEhv.nl (8.9.1/8.9.1) with IAEhv.nl id WAA22948
	for FreeBSD-gnats-submit@freebsd.org; Sun, 16 Jul 2000 22:11:08 +0200 (MET DST)
Received: by adv.iae.nl (Postfix, from userid 100)
	id 9F4BB22E6; Sun, 16 Jul 2000 22:10:30 +0200 (CEST)
Message-Id: <20000716201030.9F4BB22E6@adv.iae.nl>
Date: Sun, 16 Jul 2000 22:10:30 +0200 (CEST)
From: Arjan de Vet <Arjan.deVet@adv.iae.nl>
Reply-To: Arjan.deVet@adv.iae.nl
To: FreeBSD-gnats-submit@freebsd.org
Subject: restore does not set access/modification times correctly for immutable files
X-Send-Pr-Version: 3.2

>Number:         19973
>Category:       bin
>Synopsis:       restore does not set access/modification times correctly for immutable files
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 16 13:20:00 PDT 2000
>Closed-Date:    Fri Jul 21 02:00:19 PDT 2000
>Last-Modified:  Fri Jul 21 02:00:50 PDT 2000
>Originator:     Arjan de Vet
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
>Environment:

FreeBSD adv.iae.nl 4.0-STABLE FreeBSD 4.0-STABLE #23: Sat Jul 15 17:20:14 CEST 2000     root@adv.iae.nl:/usr/src/sys/compile/ADV  i386

>Description:

When restoring some tapes I noticed that some files did not get their
original access and modification timestamps but the current time
instead. I found out that these were all immutable files.

The restore program sets the file flags on restored files with
(f)chflags before setting the times with utimes, causing the utimes call
to fail. By reversing these calls the times get set correctly for
immutable files.

>How-To-Repeat:

Dump the root fs to a file or tape and restore it somewhere else. The
restored kernel file (normally immutable) will have different access and
modification times when compared with the original /kernel file.

>Fix:

Index: dirs.c
===================================================================
RCS file: /home/freebsd/CVS/src/sbin/restore/dirs.c,v
retrieving revision 1.14
diff -u -r1.14 dirs.c
--- dirs.c	1999/08/28 00:14:05	1.14
+++ dirs.c	2000/07/15 14:33:15
@@ -631,8 +631,8 @@
 			cp = myname(ep);
 			(void) chown(cp, node.uid, node.gid);
 			(void) chmod(cp, node.mode);
-			(void) chflags(cp, node.flags);
 			utimes(cp, node.timep);
+			(void) chflags(cp, node.flags);
 			ep->e_flags &= ~NEW;
 		}
 	}
Index: tape.c
===================================================================
RCS file: /home/freebsd/CVS/src/sbin/restore/tape.c,v
retrieving revision 1.16
diff -u -r1.16 tape.c
--- tape.c	1999/08/28 00:14:08	1.16
+++ tape.c	2000/07/15 14:33:15
@@ -581,9 +581,9 @@
 		}
 		(void) chown(name, curfile.dip->di_uid, curfile.dip->di_gid);
 		(void) chmod(name, mode);
+		utimes(name, timep);
 		(void) chflags(name, flags);
 		skipfile();
-		utimes(name, timep);
 		return (GOOD);
 
 	case IFCHR:
@@ -603,9 +603,9 @@
 		}
 		(void) chown(name, curfile.dip->di_uid, curfile.dip->di_gid);
 		(void) chmod(name, mode);
+		utimes(name, timep);
 		(void) chflags(name, flags);
 		skipfile();
-		utimes(name, timep);
 		return (GOOD);
 
 	case IFREG:
@@ -625,10 +625,10 @@
 		}
 		(void) fchown(ofile, curfile.dip->di_uid, curfile.dip->di_gid);
 		(void) fchmod(ofile, mode);
-		(void) fchflags(ofile, flags);
 		getfile(xtrfile, xtrskip);
 		(void) close(ofile);
 		utimes(name, timep);
+		(void) chflags(name, flags);
 		return (GOOD);
 	}
 	/* NOTREACHED */


>Release-Note:
>Audit-Trail:

From: David Malone <dwmalone@maths.tcd.ie>
To: Arjan de Vet <Arjan.deVet@adv.iae.nl>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/19973: restore does not set access/modification times correctly for immutable files
Date: Sun, 16 Jul 2000 23:09:28 +0100

 On Sun, Jul 16, 2000 at 10:10:30PM +0200, Arjan de Vet wrote:
 
 > When restoring some tapes I noticed that some files did not get their
 > original access and modification timestamps but the current time
 > instead. I found out that these were all immutable files.
 
 The included patch seems reasonable. Anyone object to my committing it?
 
 	David.
 
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Sun Jul 16 16:22:38 PDT 2000 
Responsible-Changed-Why:  
I've committed the patch from -current, I'll close the PR when I merge it to 
RELENG_4. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=19973 
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Fri Jul 21 02:00:19 PDT 2000 
State-Changed-Why:  
Committed to HEAD and RELENG_4, thanks. 

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