]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: only save entry for some entry types
authorLennart Poettering <lennart@poettering.net>
Tue, 25 Feb 2025 11:34:49 +0000 (12:34 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 25 Feb 2025 20:14:27 +0000 (21:14 +0100)
Much like the previous one, let's also condition the entry selection
saving on entry types.

src/boot/boot.c

index 62be8ec0a3e3695f2b23aa9b7b8649d18e7f3236..1493b31c8daefb596fd78e8f0dae293ceb5384d1 100644 (file)
@@ -76,6 +76,9 @@ typedef enum LoaderType {
 /* Whether to do random seed management (only we invoke Linux) */
 #define LOADER_TYPE_PROCESS_RANDOM_SEED(t) IN_SET(t, LOADER_LINUX, LOADER_UKI, LOADER_TYPE2_UKI)
 
+/* Whether to persistently save the selected entry in an EFI variable, if that's requested. */
+#define LOADER_TYPE_SAVE_ENTRY(t) IN_SET(t, LOADER_EFI, LOADER_LINUX, LOADER_UKI, LOADER_UKI_URL, LOADER_TYPE2_UKI)
+
 typedef struct BootEntry {
         char16_t *id;         /* The unique identifier for this entry (typically the filename of the file defining the entry, possibly suffixed with a profile id) */
         char16_t *id_without_profile; /* same, but without any profile id suffixed */
@@ -2675,7 +2678,9 @@ static void config_write_entries_to_variable(Config *config) {
 static void save_selected_entry(const Config *config, const BootEntry *entry) {
         assert(config);
         assert(entry);
-        assert(entry->loader || !entry->call);
+
+        if (!LOADER_TYPE_SAVE_ENTRY(entry->type))
+                return;
 
         /* Always export the selected boot entry to the system in a volatile var. */
         (void) efivar_set_str16(MAKE_GUID_PTR(LOADER), u"LoaderEntrySelected", entry->id, 0);