]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot-entry: prioritize machine ID only when it is not randomly generated
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 29 Mar 2023 02:14:02 +0000 (11:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 11 Apr 2023 23:31:50 +0000 (08:31 +0900)
Preparation for later commits. The parameter will be used in
kernel-install later.

src/boot/bootctl-util.c
src/shared/boot-entry.c
src/shared/boot-entry.h

index d93cc20318419fc7671c9d5bb0d9ed19e63b3008..7259f177a8031c2e44ea10a5749cbfc5aaae25ca 100644 (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)
index 90e72bd75476f8c37a85ca2aafa3b01919d5d6b7..23877fecba7c9be14f21b35a07bf5276180eb50b 100644 (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));
index 97b30702bceaaae83d2a92d91706979dbb6cc743..73781a9027d6a5938a6c78f98d207a8be51ff4cc 100644 (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. */