]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Update bootspec.c to match previous changes.
authorSpencer Michaels <sxmichaels@gmail.com>
Wed, 13 Nov 2019 02:45:50 +0000 (18:45 -0800)
committerSpencer Michaels <sxmichaels@gmail.com>
Tue, 19 Nov 2019 06:59:51 +0000 (22:59 -0800)
bootspec.c, which is used by bootctl and systemctl, computes bootloaders
entry IDs independently from systemd-boot. This commit updates
the ID computation in bootspec.c to be in line with the previous few
commits altering boot.c.

src/shared/bootspec.c

index 4f750dc1da1b50c282576429529bd0024a3b2b63..ff6d5666bce6a3871fa35b21b6ebc3db126ba54e 100644 (file)
@@ -73,12 +73,12 @@ static int boot_entry_load(
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry file suffix: %s", path);
 
         b = basename(path);
-        tmp.id = strndup(b, c - b);
+        tmp.id = strdup(b);
         if (!tmp.id)
                 return log_oom();
 
         if (!efi_loader_entry_name_valid(tmp.id))
-                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry filename: %s", path);
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry: %s", tmp.id);
 
         tmp.path = strdup(path);
         if (!tmp.path)
@@ -283,12 +283,13 @@ static int boot_entry_load_unified(
                 const char *cmdline,
                 BootEntry *ret) {
 
-        _cleanup_free_ char *os_pretty_name = NULL, *os_id = NULL, *version_id = NULL, *build_id = NULL;
+        _cleanup_free_ char *os_pretty_name = NULL;
         _cleanup_(boot_entry_free) BootEntry tmp = {
                 .type = BOOT_ENTRY_UNIFIED,
         };
         _cleanup_fclose_ FILE *f = NULL;
         const char *k;
+        char *b;
         int r;
 
         assert(root);
@@ -303,18 +304,15 @@ static int boot_entry_load_unified(
         if (!f)
                 return log_error_errno(errno, "Failed to open os-release buffer: %m");
 
-        r = parse_env_file(f, "os-release",
-                           "PRETTY_NAME", &os_pretty_name,
-                           "ID", &os_id,
-                           "VERSION_ID", &version_id,
-                           "BUILD_ID", &build_id);
+        r = parse_env_file(f, "os-release", "PRETTY_NAME", &os_pretty_name);
         if (r < 0)
                 return log_error_errno(r, "Failed to parse os-release data from unified kernel image %s: %m", path);
 
-        if (!os_pretty_name || !os_id || !(version_id || build_id))
+        if (!os_pretty_name)
                 return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Missing fields in os-release data from unified kernel image %s, refusing.", path);
 
-        tmp.id = strjoin(os_id, "-", version_id ?: build_id);
+        b = basename(path);
+        tmp.id = strdup(b);
         if (!tmp.id)
                 return log_oom();