From: Spencer Michaels Date: Wed, 13 Nov 2019 02:45:50 +0000 (-0800) Subject: boot: Update bootspec.c to match previous changes. X-Git-Tag: v245-rc1~313^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ae474efc3f6508bc4a0e50505f205f0b0b7c7617;p=thirdparty%2Fsystemd.git boot: Update bootspec.c to match previous changes. 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. --- diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 4f750dc1da1..ff6d5666bce 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -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();