diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md index e81eaf2a35..838cc7e4cf 100644 --- a/docs/ENVIRONMENT.md +++ b/docs/ENVIRONMENT.md @@ -222,3 +222,9 @@ systemd-remount-fs: directory is remounted writable. This is primarily used by systemd-gpt-auto-generator to ensure the root partition is mounted writable in accordance to the GPT partition flags. + +systemd-firstboot and localectl: + +* `SYSTEMD_LIST_NON_UTF8_LOCALES=1` – if set non-UTF-8 locales are listed among + the installed ones. By default non-UTF-8 locales are suppressed from the + selection, since we are living in the 21st century. diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c index 17302abf58..039e965bc4 100644 --- a/src/basic/locale-util.c +++ b/src/basic/locale-util.c @@ -211,6 +211,25 @@ int get_locales(char ***ret) { if (!l) return -ENOMEM; + r = getenv_bool("SYSTEMD_LIST_NON_UTF8_LOCALES"); + if (r == -ENXIO || r == 0) { + char **a, **b; + + /* Filter out non-UTF-8 locales, because it's 2019, by default */ + for (a = b = l; *a; a++) { + + if (endswith(*a, "UTF-8") || + strstr(*a, ".UTF-8@")) + *(b++) = *a; + else + free(*a); + } + + *b = NULL; + + } else if (r < 0) + log_debug_errno(r, "Failed to parse $SYSTEMD_LIST_NON_UTF8_LOCALES as boolean"); + strv_sort(l); *ret = TAKE_PTR(l);