PR25739: debuginfod correct mtime for fdcache'd files
authorFrank Ch. Eigler <fche@redhat.com>
Sat, 28 Mar 2020 19:57:09 +0000 (15:57 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Sat, 28 Mar 2020 19:59:49 +0000 (15:59 -0400)
Files extracted from archives then left in the fdcache need to get get
their mtime set consistently, so that a subsequent cache-hit fetch can
relay the correct mtime to clients.

Reported-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
debuginfod/ChangeLog
debuginfod/debuginfod.cxx
tests/ChangeLog
tests/run-debuginfod-find.sh

index 6fc4c09..ec5d574 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-28  Frank Ch. Eigler  <fche@redhat.com>
+
+       * debuginfod.cxx (handle_buildid_r_match): During archive
+       extraction / fdcache prefetching, set the mtime of each
+       file in the cache.
+
 2020-03-27  Frank Ch. Eigler  <fche@redhat.com>
 
        * debuginfod-find.c (main): Extract buildid from /binary/ if
index 74eb443..9f08a68 100644 (file)
@@ -1362,6 +1362,13 @@ handle_buildid_r_match (int64_t b_mtime,
           throw archive_exception(a, "cannot extract file");
         }
 
+      // Set the mtime so the fdcache file mtimes, even prefetched ones,
+      // propagate to future webapi clients.
+      struct timeval tvs[2];
+      tvs[0].tv_sec = tvs[1].tv_sec = archive_entry_mtime(e);
+      tvs[0].tv_usec = tvs[1].tv_usec = 0;
+      (void) futimes (fd, tvs);  /* best effort */
+
       if (r != 0) // stage 3
         {
           // NB: now we know we have a complete reusable file; make fdcache
index 66df34c..96e0642 100644 (file)
@@ -1,3 +1,7 @@
+2020-03-28  Frank Ch. Eigler  <fche@redhat.com>
+
+       * run-debuginfod-find.sh: Test timestamps of archive-origin files.
+
 2020-03-27  Frank Ch. Eigler  <fche@redhat.com>
 
        * run-debuginfod-find.sh: Test /path/-based debuginfod-find.
index bba04c1..7faad33 100755 (executable)
@@ -284,22 +284,27 @@ archive_test() {
     buildid=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
              -a $filename | grep 'Build ID' | cut -d ' ' -f 7`
     test $__BUILDID = $buildid
+    # check that timestamps are plausible - older than the near-present (tmpdir mtime)
+    test $filename -ot `pwd`
 
     # run again to assure that fdcache is being enjoyed
     filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $__BUILDID`
     buildid=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
              -a $filename | grep 'Build ID' | cut -d ' ' -f 7`
     test $__BUILDID = $buildid
+    test $filename -ot `pwd`
 
     filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $__BUILDID`
     buildid=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
              -a $filename | grep 'Build ID' | cut -d ' ' -f 7`
     test $__BUILDID = $buildid
+    test $filename -ot `pwd`
 
     if test "x$__SOURCEPATH" != "x"; then
         filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $__BUILDID $__SOURCEPATH`
         hash=`cat $filename | sha1sum | awk '{print $1}'`
         test $__SOURCESHA1 = $hash
+        test $filename -ot `pwd`
     fi
 }