Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Jul 2000 22:10:30 +0200 (CEST)
From:      Arjan de Vet <Arjan.deVet@adv.iae.nl>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/19973: restore does not set access/modification times correctly for immutable files
Message-ID:  <20000716201030.9F4BB22E6@adv.iae.nl>

next in thread | raw e-mail | index | archive | help

>Number:         19973
>Category:       bin
>Synopsis:       restore does not set access/modification times correctly for immutable files
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 16 13:20:00 PDT 2000
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000716201030.9F4BB22E6>