1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 07:51:21 +03:00

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.
This commit is contained in:
Spencer Michaels 2019-11-12 18:45:50 -08:00
parent 10d0024a07
commit ae474efc3f

View 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();