]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: Don't touch access time of new files
authorJan Alexander Steffens (heftig) <heftig@archlinux.org>
Fri, 24 Mar 2023 00:48:04 +0000 (01:48 +0100)
committerFrank Ch. Eigler <fche@redhat.com>
Thu, 30 Mar 2023 18:56:22 +0000 (14:56 -0400)
Instead of copying the mtime, which might be far in the past, don't
touch the access time. This will prevent cache cleaning from considering
the file as old immediately.

Signed-off-by: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
debuginfod/ChangeLog
debuginfod/debuginfod-client.c
debuginfod/debuginfod.cxx

index c8de6ca0d3ff592fc85b32afc99ff67dc7315eb8..c8c562325745595526c809fbf3f48eab3b242caf 100644 (file)
@@ -1,3 +1,9 @@
+2023-03-30  Jan Alexander Steffens (heftig) <heftig@archlinux.org>
+
+       * debuginfod-client.c (debuginfod_query_server): Don't modify
+       atime unintentionally.
+       * debuginfod.cxx (extract_section, handle_buildid_r_match): Ditto.
+
 2023-03-30  Aaron Merey  <amerey@redhat.com>
 
        * debuginfod-client.c (debuginfod_query_server): Avoid sscanf on
index 5dfc8e628917f46a475a3ec2c8c1f552fd9c4b34..7d0b153e1f91cbb21bfd33bdcdc41e88acdfd9de 100644 (file)
@@ -1718,13 +1718,15 @@ debuginfod_query_server (debuginfod_client *c,
 #else
   CURLcode curl_res = curl_easy_getinfo(verified_handle, CURLINFO_FILETIME, (void*) &mtime);
 #endif
-  if (curl_res != CURLE_OK)
-    mtime = time(NULL); /* fall back to current time */
-
-  struct timespec tvs[2];
-  tvs[0].tv_sec = tvs[1].tv_sec = mtime;
-  tvs[0].tv_nsec = tvs[1].tv_nsec = 0;
-  (void) futimens (fd, tvs);  /* best effort */
+  if (curl_res == CURLE_OK)
+    {
+      struct timespec tvs[2];
+      tvs[0].tv_sec = 0;
+      tvs[0].tv_nsec = UTIME_OMIT;
+      tvs[1].tv_sec = mtime;
+      tvs[1].tv_nsec = 0;
+      (void) futimens (fd, tvs);  /* best effort */
+    }
 
   /* PR27571: make cache files casually unwriteable; dirs are already 0700 */
   (void) fchmod(fd, 0400);
index b39c0591770cfbf9cdea3f919a38c21b7a0b26a2..5ef6cc32189b5669bbbdfe247a1a67122d574b94 100644 (file)
@@ -1639,7 +1639,9 @@ extract_section (int elf_fd, int64_t parent_mtime,
              if (fstat (elf_fd, &fs) != 0)
                throw libc_exception (errno, "cannot fstat file");
 
-             tvs[0] = tvs[1] = fs.st_mtim;
+             tvs[0].tv_sec = 0;
+             tvs[0].tv_nsec = UTIME_OMIT;
+             tvs[1] = fs.st_mtim;
              (void) futimens (fd, tvs);
 
              /* Add to fdcache.  */
@@ -1951,8 +1953,10 @@ handle_buildid_r_match (bool internal_req_p,
       // Set the mtime so the fdcache file mtimes, even prefetched ones,
       // propagate to future webapi clients.
       struct timespec tvs[2];
-      tvs[0].tv_sec = tvs[1].tv_sec = archive_entry_mtime(e);
-      tvs[0].tv_nsec = tvs[1].tv_nsec = archive_entry_mtime_nsec(e);
+      tvs[0].tv_sec = 0;
+      tvs[0].tv_nsec = UTIME_OMIT;
+      tvs[1].tv_sec = archive_entry_mtime(e);
+      tvs[1].tv_nsec = archive_entry_mtime_nsec(e);
       (void) futimens (fd, tvs);  /* best effort */
 
       if (r != 0) // stage 3