#include <stdio.h>
#include <linux/magic.h>
+#include <unistd.h>
#include "sd-device.h"
#include "sd-id128.h"
#include "parse-util.h"
#include "path-util.h"
#include "pe-header.h"
+#include "sort-util.h"
#include "stat-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "unaligned.h"
+#include "util.h"
#include "virt.h"
static void boot_entry_free(BootEntry *entry) {
free(config->editor);
free(config->auto_entries);
free(config->auto_firmware);
+ free(config->console_mode);
free(config->entry_oneshot);
free(config->entry_default);
if (!k)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Path is not below root: %s", path);
- f = fmemopen((void*) osrelease, strlen(osrelease), "r");
+ f = fmemopen_unlocked((void*) osrelease, strlen(osrelease), "r");
if (!f)
return log_error_errno(errno, "Failed to open os-release buffer: %m");
n = pread(fd, k, size, offset);
if (n < 0)
return log_error_errno(errno, "Failed to read section payload: %m");
- if (n != size)
+ if ((size_t) n != size)
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read while reading section payload, refusing:");
/* Allow one trailing NUL byte, but nothing more. */
}
r = find_esp_and_warn(override_esp_path, false, &esp_where, NULL, NULL, NULL, NULL);
- if (r == -ENOKEY) /* find_esp_and_warn() doesn't warn about this case */
- return log_error_errno(r, "Cannot find the ESP partition mount point.");
- if (r < 0) /* But it logs about all these cases, hence don't log here again */
+ if (r < 0) /* we don't log about ENOKEY here, but propagate it, leaving it to the caller to log */
return r;
r = find_xbootldr_and_warn(override_xbootldr_path, false, &xbootldr_where, NULL);
"auto-reboot-to-firmware-setup", "Reboot Into Firmware Interface",
};
- _cleanup_free_ char **found_by_loader = NULL;
+ _cleanup_strv_free_ char **found_by_loader = NULL;
size_t n_allocated;
char **i;
int r;
n_allocated = config->n_entries;
STRV_FOREACH(i, found_by_loader) {
- _cleanup_free_ char *c = NULL, *t = NULL;
+ _cleanup_free_ char *c = NULL, *t = NULL, *p = NULL;
char **a, **b;
if (boot_config_has_entry(config, *i))
break;
}
+ p = efi_variable_path(EFI_VENDOR_LOADER, "LoaderEntries");
+ if (!p)
+ return log_oom();
+
if (!GREEDY_REALLOC0(config->entries, n_allocated, config->n_entries + 1))
return log_oom();
.type = BOOT_ENTRY_LOADER,
.id = TAKE_PTR(c),
.title = TAKE_PTR(t),
+ .path = TAKE_PTR(p),
};
}
return 0;
}
-
-static const char* const boot_entry_type_table[_BOOT_ENTRY_MAX] = {
- [BOOT_ENTRY_CONF] = "conf",
- [BOOT_ENTRY_UNIFIED] = "unified",
- [BOOT_ENTRY_LOADER] = "loader",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(boot_entry_type, BootEntryType);