1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-15 09:57:39 +03:00

boot-entry: prioritize machine ID only when it is not randomly generated

Preparation for later commits. The parameter will be used in
kernel-install later.
This commit is contained in:
Yu Watanabe 2023-03-29 11:14:02 +09:00
parent 965b481d9b
commit 3b5fc5fb1b
3 changed files with 14 additions and 3 deletions

View File

@ -120,6 +120,7 @@ int settle_entry_token(void) {
arg_root,
etc_kernel(),
arg_machine_id,
/* machine_id_is_random = */ false,
&arg_entry_token_type,
&arg_entry_token);
if (r < 0)

View File

@ -115,6 +115,7 @@ int boot_entry_token_ensure(
const char *root,
const char *etc_kernel,
sd_id128_t machine_id,
bool machine_id_is_random,
BootEntryTokenType *type,
char **token) {
@ -133,14 +134,22 @@ int boot_entry_token_ensure(
if (r != 0)
return r;
r = entry_token_from_machine_id(machine_id, type, token);
if (r != 0)
return r;
if (!machine_id_is_random) {
r = entry_token_from_machine_id(machine_id, type, token);
if (r != 0)
return r;
}
r = entry_token_from_os_release(root, type, token);
if (r != 0)
return r;
if (machine_id_is_random) {
r = entry_token_from_machine_id(machine_id, type, token);
if (r != 0)
return r;
}
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"No machine ID set, and %s/etc/os-release carries no ID=/IMAGE_ID= fields.",
strempty(root));

View File

@ -19,6 +19,7 @@ int boot_entry_token_ensure(
const char *root,
const char *etc_kernel, /* will be prefixed with root, typically /etc/kernel. */
sd_id128_t machine_id,
bool machine_id_is_random,
BootEntryTokenType *type, /* input and output */
char **token); /* output, but do not pass uninitialized value. */