From nobody@FreeBSD.org  Mon Jun 23 22:23:34 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 12DBE106567A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 23 Jun 2008 22:23:34 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id ED7808FC20
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 23 Jun 2008 22:23:33 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m5NMNWq7016006
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 23 Jun 2008 22:23:33 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m5NMNWeX016005;
	Mon, 23 Jun 2008 22:23:32 GMT
	(envelope-from nobody)
Message-Id: <200806232223.m5NMNWeX016005@www.freebsd.org>
Date: Mon, 23 Jun 2008 22:23:32 GMT
From: Peter Schuller <peter.schuller@infidyne.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: bsdtar creates files with bogus access times
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         124915
>Category:       bin
>Synopsis:       bsdtar(1) creates files with bogus access times
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kientzle
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 23 22:30:02 UTC 2008
>Closed-Date:    Sun Aug 31 05:02:35 UTC 2008
>Last-Modified:  Mon Sep  1 03:00:18 UTC 2008
>Originator:     Peter Schuller
>Release:        7.0-RELEASE-p1
>Organization:
>Environment:
FreeBSD host 7.0-RELEASE-p1 FreeBSD 7.0-RELEASE-p1 #2: Sat Apr 19 19:15:39 CEST 2008     user@host:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
When extracting files, bsdtar creates files with a bogus access time of 0 seconds since the epoch. Other than being generally unexpected (to me), it has the practical implication that on a system running tmpwatch/tmpreaper, things untarred by bsdtar don't survive for long.

Unless the archive preserves access time and bsdtar is asked to preserve it (I don't believe this is supported however?), I would expect the access time to remain untouched, or at least set to >= creation time.
>How-To-Repeat:
% ls -l
total 0
% touch testfile
% stat -x testfile
  File: "testfile"
  Size: 0            FileType: Regular File
  Mode: (0644/-rw-r--r--)         Uid: ( 1001/   scode)  Gid: (    0/   wheel)
Device: 98,4164878385   Inode: 1424746    Links: 1
Access: Tue Jun 24 00:20:59 2008
Modify: Tue Jun 24 00:20:59 2008
Change: Tue Jun 24 00:20:59 2008
% tar -cf testfile.tar testfile
% tar -xf testfile.tar
% stat -x testfile
  File: "testfile"
  Size: 0            FileType: Regular File
  Mode: (0644/-rw-r--r--)         Uid: ( 1001/   scode)  Gid: (    0/   wheel)
Device: 98,4164878385   Inode: 1424748    Links: 1
Access: Thu Jan  1 01:00:00 1970
Modify: Tue Jun 24 00:20:59 2008
Change: Tue Jun 24 00:21:18 2008

>Fix:
No patch. Determined that bsdtar uses archive_read_extract() for extraction, but did not dig into the archive library.


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->kientzle 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Tue Jun 24 07:07:49 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124915 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/124915: commit references a PR
Date: Sun, 31 Aug 2008 04:45:50 +0000 (UTC)

 kientzle    2008-08-31 04:45:21 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_7)
     lib/libarchive       archive_write_disk.c 
     lib/libarchive/test  test_write_disk.c 
   Log:
   SVN rev 182512 on 2008-08-31 04:45:21Z by kientzle
   
   MFC r182360,r182470: If atime isn't specified, restore atime == mtime.
   
   PR:             bin/124915
   
   Revision  Changes    Path
   1.17.2.8  +5 -0      src/lib/libarchive/archive_write_disk.c
   1.6.2.3   +6 -1      src/lib/libarchive/test/test_write_disk.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/124915: commit references a PR
Date: Sun, 31 Aug 2008 04:47:06 +0000 (UTC)

 kientzle    2008-08-31 04:46:36 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     lib/libarchive       archive_write_disk.c 
     lib/libarchive/test  test_write_disk.c 
   Log:
   SVN rev 182513 on 2008-08-31 04:46:36Z by kientzle
   
   MFC r182360, r182470: If atime isn't specified, restore atime == mtime.
   
   PR:             bin/124915
   
   Revision   Changes    Path
   1.12.2.17  +5 -0      src/lib/libarchive/archive_write_disk.c
   1.9.2.5    +6 -1      src/lib/libarchive/test/test_write_disk.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"

State-Changed-From-To: open->closed 
State-Changed-By: kientzle 
State-Changed-When: Sun Aug 31 04:59:31 UTC 2008 
State-Changed-Why:  
Fixed in -CURRENT (r182360), 7-STABLE (r182512), and 6-STABLE (r182512). 

If the archive doesn't include an atime value (most tar archives 
don't), the atime will be set to match the mtime. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=124915 

From: Peter Schuller <peter.schuller@infidyne.com>
To: bug-followup@freebsd.org,
 peter.schuller@infidyne.com
Cc: kientzle@freebsd.org
Subject: Re: bin/124915: bsdtar(1) creates files with bogus access times
Date: Sun, 31 Aug 2008 09:56:25 +0200

 --nextPart1739802.IhBXhBAIcC
 Content-Type: text/plain;
   charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 =46or the record, as a user, I would consider setting atime to mtime to be=
 =20
 unexpected as well.
 
 It is better than setting it to 0 of course, but I would expect the atime t=
 o=20
 be set to the *actual* atime (meaning, the time it was extracted on the loc=
 al=20
 system). This does seem to be what gtar is doing (FYI, not trying to invoke=
 =20
 gtar as the standard).
 
 The motivation for me is that I only see two use cases of atime tar dealing=
 =20
 with atime. One case is when doing a backup/restore with atime preserved. i=
 n=20
 this case it makes sense to preserve it. But then in this case you should d=
 o=20
 just that - preserve it.
 
 The otherwise typical use of the atime is the actual local access time for=
 =20
 various purposes (security auditing, tmp cleaning, finding unused large=20
 garbage, etc).
 
 Barring the backup-and-restore case, I don't see when it is ever useful to =
 set=20
 the atime to the mtime, while there are clearly cases when it does cause=20
 problems (e.g. the "grab a tarball and have tmpwatch/tmpreaper kill it in a=
 n=20
 hour").
 
 (My use of ">=3D creation time" (modification time) in the original bug rep=
 ort=20
 was mostly meant to suggest that setting it to < creation time (modificatio=
 n=20
 time) makes no sense at all unless preserving.)
 
 =2D-=20
 / Peter Schuller
 
 PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller@infidyne.com>'
 Key retrieval: Send an E-Mail to getpgpkey@scode.org
 E-Mail: peter.schuller@infidyne.com Web: http://www.scode.org
 
 
 --nextPart1739802.IhBXhBAIcC
 Content-Type: application/pgp-signature; name=signature.asc 
 Content-Description: This is a digitally signed message part.
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.9 (FreeBSD)
 
 iEYEABECAAYFAki6TrIACgkQDNor2+l1i31r/gCfewie/Fs6u4fclIVTRyBr+GJp
 +vYAn24srVBDdq7XKaebWSChYx03kn7L
 =6kTG
 -----END PGP SIGNATURE-----
 
 --nextPart1739802.IhBXhBAIcC--

From: Tim Kientzle <kientzle@freebsd.org>
To: Peter Schuller <peter.schuller@infidyne.com>
Cc: bug-followup@freebsd.org
Subject: Re: bin/124915: bsdtar(1) creates files with bogus access times
Date: Sun, 31 Aug 2008 13:34:39 -0700

 Peter Schuller wrote:
 > For the record, as a user, I would consider setting atime to
 > mtime to be unexpected as well.
 > 
 > It is better than setting it to 0 of course, but I would expect
 > the atime to be set to the *actual* atime...
 
 There are several different times that could be used
 by the restore code if the atime is unavailable:
 
   1. mtime (or some other timestamp from the archive, though
      practically speaking, that's always going to be mtime)
   2. "start time" (the time at which tar was started)
   3. the current time
   4. the atime assigned by the system when the object
      was created
 
 I prefer (2) to (3) because the latter requires an extra
 syscall for every entry.
 
 Options (3) and (4) differ primarily on filesystems mounted
 with "noatime."  Unfortunately, option (4) demands that I
 stat() the file before setting the time in order to find
 out what atime the system assigned.  Again, I'm reluctant
 to go down that path.  (There are a very few cases where
 tar does currently stat() something it has just created
 in order to find out how the system interpreted the request,
 but I'm trying to minimize those cases.)
 
 I'm pretty ambivalent between options (1) and (2).  Both
 are equally easy to do.
 
 I'm getting ready to merge some code from Perforce that
 does more careful tracking of missing timestamps.  With that
 code, I intend to skip the time update entirely if neither
 mtime nor atime is provided, though that should never
 happen with tar.
 
 Tim

From: Peter Schuller <peter.schuller@infidyne.com>
To: Tim Kientzle <kientzle@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: bin/124915: bsdtar(1) creates files with bogus access times
Date: Sun, 31 Aug 2008 23:22:50 +0200

 --HcAYCG3uE/tztfnV
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 > There are several different times that could be used
 > by the restore code if the atime is unavailable:
 >=20
 >   1. mtime (or some other timestamp from the archive, though
 >      practically speaking, that's always going to be mtime)
 >   2. "start time" (the time at which tar was started)
 >   3. the current time
 >   4. the atime assigned by the system when the object
 >      was created
 
 For most major practical uses, the most important thing from my
 perspective is that it is not (1) and not the beginning of the epoch.
 
 With respect to (2), vs (3), vs (4), I am not the most well-informed
 person to be having an opinion on this, but should you be interested:
 
 > I prefer (2) to (3) because the latter requires an extra
 > syscall for every entry.
 
 This sounds good to me. (3) to me feels more correct, but (2) is
 sufficiently close that for practical purposes it should not matter.
 
 > Options (3) and (4) differ primarily on filesystems mounted
 > with "noatime."  Unfortunately, option (4) demands that I
 > stat() the file before setting the time in order to find
 > out what atime the system assigned.  Again, I'm reluctant
 > to go down that path.  (There are a very few cases where
 > tar does currently stat() something it has just created
 > in order to find out how the system interpreted the request,
 > but I'm trying to minimize those cases.)
 
 I don't know off-hand what stat() will return on noatime mounted
 fs:es, but presumably it's 0, the current time, or some other kind of
 arbitrary value. I question whether whatever is returned can ever be
 more useful than the "correct" atime as determined by otherwise normal
 policy of the tar extraction. (If we want the time of objection
 creation that falls back to (4) independently of noatime mounts).
 
 If the returned value is not defined/standard, it feels, if anything,
 safer to use (2) or (3) anyway to ensure it is sensible. Thus it won't
 break if a future change causes atime to be reported as epoch for
 example, or the time the filesystem was mounted, etc.
 
 --=20
 / Peter Schuller
 
 PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller@infidyne.com>'
 Key retrieval: Send an E-Mail to getpgpkey@scode.org
 E-Mail: peter.schuller@infidyne.com Web: http://www.scode.org
 
 
 --HcAYCG3uE/tztfnV
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.9 (FreeBSD)
 
 iEYEARECAAYFAki7C6kACgkQDNor2+l1i30PdgCdGphXFfvL6nTqD3Ok2e5Ip3b5
 s6wAnApSLfPovQMPjmICzO7iWsuBwQEe
 =tiee
 -----END PGP SIGNATURE-----
 
 --HcAYCG3uE/tztfnV--

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/124915: commit references a PR
Date: Mon,  1 Sep 2008 02:50:57 +0000 (UTC)

 kientzle    2008-09-01 02:50:24 UTC
 
   FreeBSD src repository
 
   Modified files:
     lib/libarchive       archive_write_disk.c 
     lib/libarchive/test  test_write_disk.c 
   Log:
   SVN rev 182587 on 2008-09-01 02:50:24Z by kientzle
   
   Use the "start_time" (time at which the restore process began)
   to fill in a missing atime instead of substituting mtime.
   
   PR:             bin/124915
   
   Revision  Changes    Path
   1.33      +13 -5     src/lib/libarchive/archive_write_disk.c
   1.12      +4 -2      src/lib/libarchive/test/test_write_disk.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
