]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/bootspec.c
update TODO
[thirdparty/systemd.git] / src / shared / bootspec.c
index b0c6e4885fa07b1473c013ed749cf2048ae22bf9..11bba2c7edfadd737d7be627fcc26432f10f4f9b 100644 (file)
@@ -15,6 +15,7 @@
 #include "device-nodes.h"
 #include "dirent-util.h"
 #include "efivars.h"
+#include "efi-loader.h"
 #include "env-file.h"
 #include "env-util.h"
 #include "fd-util.h"
@@ -35,6 +36,7 @@ static void boot_entry_free(BootEntry *entry) {
         assert(entry);
 
         free(entry->id);
+        free(entry->id_old);
         free(entry->path);
         free(entry->root);
         free(entry->title);
@@ -72,12 +74,13 @@ 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);
-        if (!tmp.id)
+        tmp.id = strdup(b);
+        tmp.id_old = strndup(b, c - b);
+        if (!tmp.id || !tmp.id_old)
                 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)
@@ -161,6 +164,7 @@ void boot_config_free(BootConfig *config) {
         free(config->auto_entries);
         free(config->auto_firmware);
         free(config->console_mode);
+        free(config->random_seed_mode);
 
         free(config->entry_oneshot);
         free(config->entry_default);
@@ -226,6 +230,8 @@ static int boot_loader_read_conf(const char *path, BootConfig *config) {
                         r = free_and_strdup(&config->auto_firmware, p);
                 else if (streq(field, "console-mode"))
                         r = free_and_strdup(&config->console_mode, p);
+                else if (streq(field, "random-seed-mode"))
+                        r = free_and_strdup(&config->random_seed_mode, p);
                 else {
                         log_notice("%s:%u: Unknown line \"%s\", ignoring.", path, line, field);
                         continue;
@@ -257,7 +263,7 @@ static int boot_entries_find(
         assert(entries);
         assert(n_entries);
 
-        r = conf_files_list(&files, ".conf", NULL, 0, dir, NULL);
+        r = conf_files_list(&files, ".conf", NULL, 0, dir);
         if (r < 0)
                 return log_error_errno(r, "Failed to list files in \"%s\": %m", dir);
 
@@ -288,6 +294,7 @@ static int boot_entry_load_unified(
         };
         _cleanup_fclose_ FILE *f = NULL;
         const char *k;
+        char *b;
         int r;
 
         assert(root);
@@ -313,8 +320,10 @@ static int boot_entry_load_unified(
         if (!os_pretty_name || !os_id || !(version_id || build_id))
                 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);
-        if (!tmp.id)
+        b = basename(path);
+        tmp.id = strdup(b);
+        tmp.id_old = strjoin(os_id, "-", version_id ?: build_id);
+        if (!tmp.id || !tmp.id_old)
                 return log_oom();
 
         if (!efi_loader_entry_name_valid(tmp.id))
@@ -475,6 +484,7 @@ static int boot_entries_find_unified(
                 _cleanup_free_ char *j = NULL, *osrelease = NULL, *cmdline = NULL;
                 _cleanup_close_ int fd = -1;
 
+                dirent_ensure_type(d, de);
                 if (!dirent_is_file(de))
                         continue;
 
@@ -725,9 +735,12 @@ int boot_entries_load_config_auto(
         return boot_entries_load_config(esp_where, xbootldr_where, config);
 }
 
-#if ENABLE_EFI
-int boot_entries_augment_from_loader(BootConfig *config, bool only_auto) {
-        static const char * const title_table[] = {
+int boot_entries_augment_from_loader(
+                BootConfig *config,
+                char **found_by_loader,
+                bool only_auto) {
+
+        static const char *const title_table[] = {
                 /* Pretty names for a few well-known automatically discovered entries. */
                 "auto-osx",                      "macOS",
                 "auto-windows",                  "Windows Boot Manager",
@@ -736,22 +749,14 @@ int boot_entries_augment_from_loader(BootConfig *config, bool only_auto) {
                 "auto-reboot-to-firmware-setup", "Reboot Into Firmware Interface",
         };
 
-        _cleanup_strv_free_ char **found_by_loader = NULL;
         size_t n_allocated;
         char **i;
-        int r;
 
         assert(config);
 
         /* Let's add the entries discovered by the boot loader to the end of our list, unless they are
          * already included there. */
 
-        r = efi_loader_get_entries(&found_by_loader);
-        if (IN_SET(r, -ENOENT, -EOPNOTSUPP))
-                return log_debug_errno(r, "Boot loader reported no entries.");
-        if (r < 0)
-                return log_error_errno(r, "Failed to determine entries reported by boot loader: %m");
-
         n_allocated = config->n_entries;
 
         STRV_FOREACH(i, found_by_loader) {
@@ -793,7 +798,6 @@ int boot_entries_augment_from_loader(BootConfig *config, bool only_auto) {
 
         return 0;
 }
-#endif
 
 /********************************************************************************/
 
@@ -876,7 +880,7 @@ static int verify_esp_blkid(
         errno = 0;
         r = blkid_probe_lookup_value(b, "PART_ENTRY_NUMBER", &v, NULL);
         if (r != 0)
-                return log_error_errno(errno ?: SYNTHETIC_ERRNO(EIO), "Failed to probe partition number of \"%s\": m", node);
+                return log_error_errno(errno ?: SYNTHETIC_ERRNO(EIO), "Failed to probe partition number of \"%s\": %m", node);
         r = safe_atou32(v, &part);
         if (r < 0)
                 return log_error_errno(r, "Failed to parse PART_ENTRY_NUMBER field.");