diff options
author | Ludwig Nussel <ludwig.nussel@suse.de> | 2022-12-07 11:43:56 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-01-05 21:45:18 +0100 |
commit | 8109b2908def1b8038e0a6d3474eeca7cd143d4f (patch) | |
tree | c9fa24c965ee15f59998c60672493a750fe72325 /src/boot/bootctl-install.c | |
parent | 882b011277593e3fe17f00fee67f49cdf7ffbdc5 (diff) | |
download | systemd-8109b2908def1b8038e0a6d3474eeca7cd143d4f.tar.gz |
bootctl: print entry token as well
Diffstat (limited to 'src/boot/bootctl-install.c')
-rw-r--r-- | src/boot/bootctl-install.c | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/src/boot/bootctl-install.c b/src/boot/bootctl-install.c index d6c2feaeaf..31c2050a4a 100644 --- a/src/boot/bootctl-install.c +++ b/src/boot/bootctl-install.c @@ -95,98 +95,6 @@ static int load_etc_kernel_install_conf(void) { return 0; } -static int settle_entry_token(void) { - int r; - - switch (arg_entry_token_type) { - - case ARG_ENTRY_TOKEN_AUTO: { - _cleanup_free_ char *buf = NULL; - r = read_one_line_file("/etc/kernel/entry-token", &buf); - if (r < 0 && r != -ENOENT) - return log_error_errno(r, "Failed to read /etc/kernel/entry-token: %m"); - - if (!isempty(buf)) { - free_and_replace(arg_entry_token, buf); - arg_entry_token_type = ARG_ENTRY_TOKEN_LITERAL; - } else if (sd_id128_is_null(arg_machine_id)) { - _cleanup_free_ char *id = NULL, *image_id = NULL; - - r = parse_os_release(NULL, - "IMAGE_ID", &image_id, - "ID", &id); - if (r < 0) - return log_error_errno(r, "Failed to load /etc/os-release: %m"); - - if (!isempty(image_id)) { - free_and_replace(arg_entry_token, image_id); - arg_entry_token_type = ARG_ENTRY_TOKEN_OS_IMAGE_ID; - } else if (!isempty(id)) { - free_and_replace(arg_entry_token, id); - arg_entry_token_type = ARG_ENTRY_TOKEN_OS_ID; - } else - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No machine ID set, and /etc/os-release carries no ID=/IMAGE_ID= fields."); - } else { - r = free_and_strdup_warn(&arg_entry_token, SD_ID128_TO_STRING(arg_machine_id)); - if (r < 0) - return r; - - arg_entry_token_type = ARG_ENTRY_TOKEN_MACHINE_ID; - } - - break; - } - - case ARG_ENTRY_TOKEN_MACHINE_ID: - if (sd_id128_is_null(arg_machine_id)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No machine ID set."); - - r = free_and_strdup_warn(&arg_entry_token, SD_ID128_TO_STRING(arg_machine_id)); - if (r < 0) - return r; - - break; - - case ARG_ENTRY_TOKEN_OS_IMAGE_ID: { - _cleanup_free_ char *buf = NULL; - - r = parse_os_release(NULL, "IMAGE_ID", &buf); - if (r < 0) - return log_error_errno(r, "Failed to load /etc/os-release: %m"); - - if (isempty(buf)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "IMAGE_ID= field not set in /etc/os-release."); - - free_and_replace(arg_entry_token, buf); - break; - } - - case ARG_ENTRY_TOKEN_OS_ID: { - _cleanup_free_ char *buf = NULL; - - r = parse_os_release(NULL, "ID", &buf); - if (r < 0) - return log_error_errno(r, "Failed to load /etc/os-release: %m"); - - if (isempty(buf)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "ID= field not set in /etc/os-release."); - - free_and_replace(arg_entry_token, buf); - break; - } - - case ARG_ENTRY_TOKEN_LITERAL: - assert(!isempty(arg_entry_token)); /* already filled in by command line parser */ - break; - } - - if (isempty(arg_entry_token) || !(utf8_is_valid(arg_entry_token) && string_is_safe(arg_entry_token))) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Selected entry token not valid: %s", arg_entry_token); - - log_debug("Using entry token: %s", arg_entry_token); - return 0; -} - static bool use_boot_loader_spec_type1(void) { /* If the layout is not specified, or if it is set explicitly to "bls" we assume Boot Loader * Specification Type #1 is the chosen format for our boot loader entries */ |