Subject: bin/4515: restore(8) doesn't set regular file modification times
To: None <gnats-bugs@gnats.netbsd.org>
From: None <stephen.ma@jtec.com.au>
List: netbsd-bugs
Date: 11/17/1997 18:19:33
>Number:         4515
>Category:       bin
>Synopsis:       restore(8) doesn't set regular file modification times
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 16 23:35:01 1997
>Last-Modified:
>Originator:     stephen.ma@jtec.com.au
>Organization:
	Church of the 2nd coming of the Great Prophet Zarquon
>Release:        NetBSD-current 971112
>Environment:
System: NetBSD whitewater.jtec.com.au 1.3_ALPHA NetBSD 1.3_ALPHA (WHITEWATER) #0: Thu Nov 13 18:31:15 EST 1997 stephen@whitewater.jtec.com.au:/usr/src/sys/arch/i386/compile/WHITEWATER i386

>Description:
restore(8) doesn't set regular file modification times. Instead, the
modification time gets set to the time of restore. All other types
of restored files aren't affected

>How-To-Repeat:
Run restore on any dump file/tape. Note the file modification times
on all regular files. Also note that file mod times for all directories,
special files, links do get restored.

>Fix:
patch tape.c:
*** /usr/src/sbin/restore/tape.c	Mon Oct 20 23:41:47 1997
--- ./tape.c	Mon Nov 17 18:09:09 1997
***************
*** 623,634 ****
  			skipfile();
  			return (FAIL);
  		}
! 		(void) futimes(ofile, timep);
  		(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);
  		return (GOOD);
  	}
  	/* NOTREACHED */
--- 623,643 ----
  			skipfile();
  			return (FAIL);
  		}
! 
! 		/* fchown() must come before getfile, since we ref curfile */
  		(void) fchown(ofile, curfile.dip->di_uid, curfile.dip->di_gid);
! 
  		getfile(xtrfile, xtrskip);
  		(void) close(ofile);
+ 
+ 		/*
+ 		 * The other inode data calls should come after the close()
+ 		 * so that we don't muck up the getfile() or have the
+ 		 * getfile() change the file modification times.
+ 		 */
+ 		(void) chmod(name, mode);
+ 		(void) utimes(name, timep);
+ 		(void) chflags(name, flags);
  		return (GOOD);
  	}
  	/* NOTREACHED */
>Audit-Trail:
>Unformatted: