diff options
author | Jan Janssen <medhefgo@web.de> | 2022-06-09 10:07:06 +0200 |
---|---|---|
committer | Jan Janssen <medhefgo@web.de> | 2022-06-09 12:50:13 +0200 |
commit | 23742af5225944b5ed7db4633038b4c025660945 (patch) | |
tree | c0585dd731c1efc31638430e0b5b12d5f4089baa | |
parent | boot: Add efi_fnmatch (diff) | |
download | systemd-23742af5225944b5ed7db4633038b4c025660945.tar.xz systemd-23742af5225944b5ed7db4633038b4c025660945.zip |
boot: Drop use of MetaiMatch
A future commit will add support for unicode collation protocol that
allows case folding and comparing strings with locale awareness. But it
only operates on whole strings, so fnmatch cannot use those without a
heavy cost. Instead we just case fold the patterns instead (the IDs we
try to match are already lower case).
-rw-r--r-- | man/loader.conf.xml | 9 | ||||
-rw-r--r-- | src/boot/efi/boot.c | 15 |
2 files changed, 19 insertions, 5 deletions
diff --git a/man/loader.conf.xml b/man/loader.conf.xml index 509412ec9d..43a115dcad 100644 --- a/man/loader.conf.xml +++ b/man/loader.conf.xml @@ -110,7 +110,14 @@ </row> </tbody> </tgroup> - </table></listitem> + </table> + + <para>Supported glob wilcard patterns are <literal>?</literal>, <literal>*</literal>, and + <literal>[…]</literal> (including ranges). Note that these patterns use the same syntax as + <citerefentry><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>, but do not + support all features. In particular, set negation and named character classes are not supported. The + matching is done case-insensitively on the entry ID (as shown by <command>bootctl + list</command>).</para></listitem> </varlistentry> <varlistentry> diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 71f1227923..60e8786e3e 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -1170,7 +1170,7 @@ static void config_defaults_load_from_file(Config *config, CHAR8 *content) { } if (streq8((char *) key, "default")) { - if (value[0] == '@' && !streq8((char *) value, "@saved")) { + if (value[0] == '@' && !strcaseeq8((char *) value, "@saved")) { log_error_stall(L"Unsupported special entry identifier: %a", value); continue; } @@ -1606,6 +1606,11 @@ static void config_load_defaults(Config *config, EFI_FILE *root_dir) { (void) efivar_get(LOADER_GUID, L"LoaderEntryDefault", &config->entry_default_efivar); + strtolower16(config->entry_default_config); + strtolower16(config->entry_default_efivar); + strtolower16(config->entry_oneshot); + strtolower16(config->entry_saved); + config->use_saved_entry = streq16(config->entry_default_config, L"@saved"); config->use_saved_entry_efivar = streq16(config->entry_default_efivar, L"@saved"); if (config->use_saved_entry || config->use_saved_entry_efivar) @@ -1710,14 +1715,16 @@ static int config_entry_compare(const ConfigEntry *a, const ConfigEntry *b) { return CMP(a->tries_done, b->tries_done); } -static UINTN config_entry_find(Config *config, const CHAR16 *needle) { +static UINTN config_entry_find(Config *config, const CHAR16 *pattern) { assert(config); - if (!needle) + /* We expect pattern and entry IDs to be already case folded. */ + + if (!pattern) return IDX_INVALID; for (UINTN i = 0; i < config->entry_count; i++) - if (MetaiMatch(config->entries[i]->id, (CHAR16*) needle)) + if (efi_fnmatch(pattern, config->entries[i]->id)) return i; return IDX_INVALID; |