From b988d23367e5c16480db7adf2c3ddc887142c42c Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sat, 28 Mar 2020 15:57:09 -0400 Subject: [PATCH] PR25739: debuginfod correct mtime for fdcache'd files 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 Signed-off-by: Frank Ch. Eigler --- debuginfod/ChangeLog | 6 ++++++ debuginfod/debuginfod.cxx | 7 +++++++ tests/ChangeLog | 4 ++++ tests/run-debuginfod-find.sh | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 6fc4c09..ec5d574 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,9 @@ +2020-03-28 Frank Ch. Eigler + + * 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 * debuginfod-find.c (main): Extract buildid from /binary/ if diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index 74eb443..9f08a68 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -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 diff --git a/tests/ChangeLog b/tests/ChangeLog index 66df34c..96e0642 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2020-03-28 Frank Ch. Eigler + + * run-debuginfod-find.sh: Test timestamps of archive-origin files. + 2020-03-27 Frank Ch. Eigler * run-debuginfod-find.sh: Test /path/-based debuginfod-find. diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh index bba04c1..7faad33 100755 --- a/tests/run-debuginfod-find.sh +++ b/tests/run-debuginfod-find.sh @@ -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 } -- 2.7.4