diff options
Diffstat (limited to 'src/locale/localectl.c')
-rw-r--r-- | src/locale/localectl.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/locale/localectl.c b/src/locale/localectl.c index bf8b7b2bef..5917364d7c 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -43,6 +43,8 @@ #include "path-util.h" #include "utf8.h" #include "def.h" +#include "virt.h" +#include "fileio.h" #include "locale-util.h" static bool arg_no_pager = false; @@ -81,6 +83,53 @@ typedef struct StatusInfo { const char *x11_options; } StatusInfo; +static void print_overriden_variables(void) { + int r; + char *variables[_VARIABLE_LC_MAX] = {}; + LocaleVariable j; + bool print_warning = true; + + if (detect_container(NULL) > 0 || arg_host) + return; + + r = parse_env_file("/proc/cmdline", WHITESPACE, + "locale.LANG", &variables[VARIABLE_LANG], + "locale.LANGUAGE", &variables[VARIABLE_LANGUAGE], + "locale.LC_CTYPE", &variables[VARIABLE_LC_CTYPE], + "locale.LC_NUMERIC", &variables[VARIABLE_LC_NUMERIC], + "locale.LC_TIME", &variables[VARIABLE_LC_TIME], + "locale.LC_COLLATE", &variables[VARIABLE_LC_COLLATE], + "locale.LC_MONETARY", &variables[VARIABLE_LC_MONETARY], + "locale.LC_MESSAGES", &variables[VARIABLE_LC_MESSAGES], + "locale.LC_PAPER", &variables[VARIABLE_LC_PAPER], + "locale.LC_NAME", &variables[VARIABLE_LC_NAME], + "locale.LC_ADDRESS", &variables[VARIABLE_LC_ADDRESS], + "locale.LC_TELEPHONE", &variables[VARIABLE_LC_TELEPHONE], + "locale.LC_MEASUREMENT", &variables[VARIABLE_LC_MEASUREMENT], + "locale.LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION], + NULL); + + if (r < 0 && r != -ENOENT) { + log_warning("Failed to read /proc/cmdline: %s", strerror(-r)); + goto finish; + } + + for (j = VARIABLE_LANG; j < _VARIABLE_LC_MAX; j++) + if (variables[j]) { + if (print_warning) { + printf("Warning: Settings on Kernel Command Line override system locale settings in /etc/locale.conf\n"); + printf(" Command Line: %s=%s\n", locale_variable_to_string(j), variables[j]); + + print_warning = false; + continue; + } + printf(" %s=%s\n", locale_variable_to_string(j), variables[j]); + } + finish: + for (j = VARIABLE_LANG; j < _VARIABLE_LC_MAX; j++) + free(variables[j]); +} + static void print_status_info(StatusInfo *i) { assert(i); @@ -134,6 +183,7 @@ static int show_status(sd_bus *bus, char **args, unsigned n) { goto fail; } + print_overriden_variables(); print_status_info(&info); fail: |