X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flocale%2Flocalectl.c;h=3690f9fc892c5037a15a42a09eb3e2f537291e3e;hp=69d50076aad0f75028b11761016355f2d533d436;hb=9f03ee51a2207954ef18be79ca3e11cd14ca56fd;hpb=601185b43da638b1c74153deae01dbd518680889 diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 69d50076a..3690f9fc8 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,52 @@ 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 = 0; j < _VARIABLE_LC_MAX; j++) + if (variables[j]) { + if (print_warning) { + log_warning("Warning: Settings on kernel command line override system locale settings in /etc/locale.conf.\n" + " Command Line: %s=%s\n", locale_variable_to_string(j), variables[j]); + + print_warning = false; + } else + log_warning(" %s=%s\n", locale_variable_to_string(j), variables[j]); + } + finish: + for (j = 0; j < _VARIABLE_LC_MAX; j++) + free(variables[j]); +} + static void print_status_info(StatusInfo *i) { assert(i); @@ -134,6 +182,7 @@ static int show_status(sd_bus *bus, char **args, unsigned n) { goto fail; } + print_overriden_variables(); print_status_info(&info); fail: @@ -272,7 +321,7 @@ static int list_vconsole_keymaps(sd_bus *bus, char **args, unsigned n) { _cleanup_strv_free_ char **l = NULL; const char *dir; - keymaps = set_new(string_hash_func, string_compare_func); + keymaps = set_new(&string_hash_ops); if (!keymaps) return log_oom(); @@ -621,7 +670,7 @@ static int localectl_main(sd_bus *bus, int argc, char *argv[]) { } int main(int argc, char*argv[]) { - _cleanup_bus_unref_ sd_bus *bus = NULL; + _cleanup_bus_close_unref_ sd_bus *bus = NULL; int r; setlocale(LC_ALL, "");