]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: do not fail when the same file is updated multiple times
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 Jun 2024 07:11:23 +0000 (16:11 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 4 Aug 2025 14:43:35 +0000 (15:43 +0100)
In the second or later trial, copy_file_with_version_check() -> version_check()
fails with -ESRCH. Let's ignore the failure.

This also adds missing assertions in update_efi_boot_binaries(), and
drop redundant version check in update_efi_boot_binaries(), as version
will be anyway checked later.

Fixes a regression caused by 929f41c6528fb630753d4e2f588a8eb6c2f6a609.
Fixes #33392.

(cherry picked from commit 7107cfbf4f0bcb377f533f0dbc5b5a5ea41b41c0)

src/bootctl/bootctl-install.c

index e15c2c6bedb23ae869c08669c8ab2457f8100689..c2b2faef3b2c322ffc1241f41d4b15bf508bd38c 100644 (file)
@@ -329,6 +329,9 @@ static int update_efi_boot_binaries(const char *esp_path, const char *source_pat
         _cleanup_free_ char *p = NULL;
         int r, ret = 0;
 
+        assert(esp_path);
+        assert(source_path);
+
         r = chase_and_opendir("/EFI/BOOT", esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &p, &d);
         if (r == -ENOENT)
                 return 0;
@@ -337,7 +340,6 @@ static int update_efi_boot_binaries(const char *esp_path, const char *source_pat
 
         FOREACH_DIRENT(de, d, break) {
                 _cleanup_close_ int fd = -EBADF;
-                _cleanup_free_ char *v = NULL;
 
                 if (!endswith_no_case(de->d_name, ".efi"))
                         continue;
@@ -354,19 +356,14 @@ static int update_efi_boot_binaries(const char *esp_path, const char *source_pat
                 if (r == 0)
                         continue;
 
-                r = get_file_version(fd, &v);
-                if (r == -ESRCH)
-                        continue;  /* No version information */
-                if (r < 0)
-                        return r;
-                if (!startswith(v, "systemd-boot "))
-                        continue;
-
                 _cleanup_free_ char *dest_path = path_join(p, de->d_name);
                 if (!dest_path)
                         return log_oom();
 
-                RET_GATHER(ret, copy_file_with_version_check(source_path, dest_path, /* force = */ false));
+                r = copy_file_with_version_check(source_path, dest_path, /* force = */ false);
+                if (IN_SET(r, -ESTALE, -ESRCH))
+                        continue;
+                RET_GATHER(ret, r);
         }
 
         return ret;