diff options
author | Kay Sievers <kay@vrfy.org> | 2015-03-11 23:26:48 +0100 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2015-03-11 23:33:53 +0100 |
commit | 4db7e6d781c2d9bba4e9124d26e811dd4addc1c5 (patch) | |
tree | 7dabc81c01520a8cc0eefdf6813ea07d662be40c /src | |
parent | cgtop: fix assert when not on tty (diff) | |
download | systemd-4db7e6d781c2d9bba4e9124d26e811dd4addc1c5.tar.xz systemd-4db7e6d781c2d9bba4e9124d26e811dd4addc1c5.zip |
boot: efi - add config option to disable the command line editor
Diffstat (limited to 'src')
-rw-r--r-- | src/boot/efi/boot.c | 16 | ||||
-rw-r--r-- | src/boot/efi/util.c | 20 | ||||
-rw-r--r-- | src/boot/efi/util.h | 6 |
3 files changed, 39 insertions, 3 deletions
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index be314d8dfb..eb1a4e3b66 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -66,6 +66,7 @@ typedef struct { CHAR16 *entry_default_pattern; CHAR16 *entry_oneshot; CHAR16 *options_edit; + BOOLEAN no_editor; } Config; static VOID cursor_left(UINTN *cursor, UINTN *first) @@ -375,7 +376,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) { Print(L"console size: %d x %d\n", x, y); if (efivar_get_raw(&global_guid, L"SecureBoot", &b, &size) == EFI_SUCCESS) { - Print(L"SecureBoot: %s\n", *b > 0 ? L"enabled" : L"disabled"); + Print(L"SecureBoot: %s\n", yes_no(*b > 0)); FreePool(b); } @@ -396,6 +397,7 @@ 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"\n"); Print(L"config entry count: %d\n", config->entry_count); @@ -452,7 +454,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) { Print(L"loader '%s'\n", entry->loader); if (entry->options) Print(L"options '%s'\n", entry->options); - Print(L"auto-select %s\n", entry->no_autoselect ? L"no" : L"yes"); + Print(L"auto-select %s\n", yes_no(!entry->no_autoselect)); if (entry->call) Print(L"internal call yes\n"); @@ -769,7 +771,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->entries[idx_highlight]->type == LOADER_UNDEFINED) + if (config->no_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); @@ -998,6 +1000,14 @@ static VOID config_defaults_load_from_file(Config *config, CHAR8 *content) { StrLwr(config->entry_default_pattern); continue; } + + if (strcmpa((CHAR8 *)"editor", key) == 0) { + BOOLEAN on; + + if (EFI_ERROR(parse_boolean(value, &on))) + continue; + config->no_editor = !on; + } } } diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index 5678b50c31..ba5ed7d22f 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -69,6 +69,26 @@ UINT64 time_usec(VOID) { return 1000 * 1000 * ticks / freq; } +EFI_STATUS parse_boolean(CHAR8 *v, BOOLEAN *b) { + if (strcmpa(v, (CHAR8 *)"1") == 0 || + strcmpa(v, (CHAR8 *)"yes") == 0 || + strcmpa(v, (CHAR8 *)"y") == 0 || + strcmpa(v, (CHAR8 *)"true") == 0) { + *b = TRUE; + return EFI_SUCCESS; + } + + if (strcmpa(v, (CHAR8 *)"0") == 0 || + strcmpa(v, (CHAR8 *)"no") == 0 || + strcmpa(v, (CHAR8 *)"n") == 0 || + strcmpa(v, (CHAR8 *)"false") == 0) { + *b = FALSE; + return EFI_SUCCESS; + } + + return EFI_INVALID_PARAMETER; +} + EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, CHAR16 *name, CHAR8 *buf, UINTN size, BOOLEAN persistent) { UINT32 flags; diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index efaafd7492..4727a34d1f 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -23,6 +23,12 @@ #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0])) +static inline const CHAR16 *yes_no(BOOLEAN b) { + return b ? L"yes" : L"no"; +} + +EFI_STATUS parse_boolean(CHAR8 *v, BOOLEAN *b); + UINT64 ticks_read(void); UINT64 ticks_freq(void); UINT64 time_usec(void); |