summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2018-01-28 17:06:22 +0100
committerJan Janssen <medhefgo@web.de>2018-01-28 17:20:41 +0100
commitc1d4e298bc5b80788ab0cbfdfc066140678612a8 (patch)
tree2c060e6d3f28cc350d0c309603b4f1d3bc3b82fe /src
parent33d4ba32c93cba64832ce73c50cfd316200c0be3 (diff)
downloadsystemd-c1d4e298bc5b80788ab0cbfdfc066140678612a8.tar.gz
systemd-boot: Make automatic entries configurable
Hiding automatic entries allows for giving custom entry names like "Windows 10" instead of "Windows Boot Manager" by creating an appropriate loader file in the loader/entries folder. Note that it is already doable by renaming bootmgfw.efi (or the other auto-detected boot loaders) and then using the renamed file for a custom entry. But windows will automatically recreate the boot loader on updates, including the default EFI bootloader entry if that one is missing. Make hiding EFI reboot a separate option because there is no simple way to create it with a custom loader entry and people may still want that around while still hiding the other auto entries. Also, turn no_editor into a positive boolean name while we're touching this code.
Diffstat (limited to 'src')
-rw-r--r--src/boot/efi/boot.c44
-rw-r--r--src/shared/bootspec.c6
-rw-r--r--src/shared/bootspec.h2
3 files changed, 46 insertions, 6 deletions
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
index 9d5ea6ed93..e0438281e1 100644
--- a/src/boot/efi/boot.c
+++ b/src/boot/efi/boot.c
@@ -68,7 +68,9 @@ typedef struct {
CHAR16 *entry_default_pattern;
CHAR16 *entry_oneshot;
CHAR16 *options_edit;
- BOOLEAN no_editor;
+ BOOLEAN editor;
+ BOOLEAN auto_entries;
+ BOOLEAN auto_firmware;
} Config;
static VOID cursor_left(UINTN *cursor, UINTN *first) {
@@ -392,7 +394,9 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
Print(L"OsIndicationsSupported: %d\n", (UINT64)*b);
FreePool(b);
}
- Print(L"\n");
+
+ Print(L"\n--- press key ---\n\n");
+ console_key_read(&key, TRUE);
Print(L"timeout: %d\n", config->timeout_sec);
if (config->timeout_sec_efivar >= 0)
@@ -400,7 +404,9 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
Print(L"timeout (config): %d\n", config->timeout_sec_config);
if (config->entry_default_pattern)
Print(L"default pattern: '%s'\n", config->entry_default_pattern);
- Print(L"editor: %s\n", yes_no(!config->no_editor));
+ Print(L"editor: %s\n", yes_no(config->editor));
+ Print(L"auto-entries: %s\n", yes_no(config->auto_entries));
+ Print(L"auto-firmware: %s\n", yes_no(config->auto_firmware));
Print(L"\n");
Print(L"config entry count: %d\n", config->entry_count);
@@ -774,7 +780,7 @@ static BOOLEAN menu_run(Config *config, ConfigEntry **chosen_entry, CHAR16 *load
case KEYPRESS(0, 0, 'e'):
/* only the options of configured entries can be edited */
- if (config->no_editor || config->entries[idx_highlight]->type == LOADER_UNDEFINED)
+ if (!config->editor || config->entries[idx_highlight]->type == LOADER_UNDEFINED)
break;
uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK);
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_max-1);
@@ -1006,7 +1012,23 @@ static VOID config_defaults_load_from_file(Config *config, CHAR8 *content) {
if (EFI_ERROR(parse_boolean(value, &on)))
continue;
- config->no_editor = !on;
+ config->editor = on;
+ }
+
+ if (strcmpa((CHAR8 *)"auto-entries", key) == 0) {
+ BOOLEAN on;
+
+ if (EFI_ERROR(parse_boolean(value, &on)))
+ continue;
+ config->auto_entries = on;
+ }
+
+ if (strcmpa((CHAR8 *)"auto-firmware", key) == 0) {
+ BOOLEAN on;
+
+ if (EFI_ERROR(parse_boolean(value, &on)))
+ continue;
+ config->auto_firmware = on;
}
}
}
@@ -1144,6 +1166,10 @@ static VOID config_load_defaults(Config *config, EFI_FILE *root_dir) {
UINTN sec;
EFI_STATUS err;
+ config->editor = TRUE;
+ config->auto_entries = TRUE;
+ config->auto_firmware = TRUE;
+
err = file_read(root_dir, L"\\loader\\loader.conf", 0, 0, &content, NULL);
if (!EFI_ERROR(err))
config_defaults_load_from_file(config, content);
@@ -1428,6 +1454,9 @@ static BOOLEAN config_entry_add_loader_auto(Config *config, EFI_HANDLE *device,
ConfigEntry *entry;
EFI_STATUS err;
+ if (!config->auto_entries)
+ return FALSE;
+
/* do not add an entry for ourselves */
if (loaded_image_path && StriCmp(loader, loaded_image_path) == 0)
return FALSE;
@@ -1453,6 +1482,9 @@ static VOID config_entry_add_osx(Config *config) {
UINTN handle_count = 0;
EFI_HANDLE *handles = NULL;
+ if (!config->auto_entries)
+ return;
+
err = LibLocateHandle(ByProtocol, &FileSystemProtocol, NULL, &handle_count, &handles);
if (!EFI_ERROR(err)) {
UINTN i;
@@ -1761,7 +1793,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
L"auto-efi-default", '\0', L"EFI Default Loader", L"\\EFI\\Boot\\boot" EFI_MACHINE_TYPE_NAME ".efi");
config_entry_add_osx(&config);
- if (efivar_get_raw(&global_guid, L"OsIndicationsSupported", &b, &size) == EFI_SUCCESS) {
+ if (config.auto_firmware && efivar_get_raw(&global_guid, L"OsIndicationsSupported", &b, &size) == EFI_SUCCESS) {
UINT64 osind = (UINT64)*b;
if (osind & EFI_OS_INDICATIONS_BOOT_TO_FW_UI)
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 9c3bdd47de..8f3faeecb3 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -142,6 +142,8 @@ void boot_config_free(BootConfig *config) {
free(config->default_pattern);
free(config->timeout);
free(config->editor);
+ free(config->auto_entries);
+ free(config->auto_firmware);
free(config->entry_oneshot);
free(config->entry_default);
@@ -194,6 +196,10 @@ int boot_loader_read_conf(const char *path, BootConfig *config) {
r = free_and_strdup(&config->timeout, p);
else if (streq(buf, "editor"))
r = free_and_strdup(&config->editor, p);
+ else if (streq(buf, "auto-entries"))
+ r = free_and_strdup(&config->auto_entries, p);
+ else if (streq(buf, "auto-firmware"))
+ r = free_and_strdup(&config->auto_firmware, p);
else {
log_notice("%s:%u: Unknown line \"%s\"", path, line, buf);
continue;
diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h
index d9c641bf08..fe875454b1 100644
--- a/src/shared/bootspec.h
+++ b/src/shared/bootspec.h
@@ -40,6 +40,8 @@ typedef struct BootConfig {
char *default_pattern;
char *timeout;
char *editor;
+ char *auto_entries;
+ char *auto_firmware;
char *entry_oneshot;
char *entry_default;