Re: [systemd-devel] [PATCH 2/2] localectl: print warning when there are options given on kernel cmdline
On Thu, Oct 02, 2014 at 02:39:10PM +0200, Lennart Poettering wrote: On Wed, 24.09.14 17:18, Michal Sekletar (msekl...@redhat.com) wrote: Heya, +for (j = VARIABLE_LANG; j _VARIABLE_LC_MAX; j++) I think it is much nicer to count from an explicit 0 on here, instead of VARIABLE_LANG, since this makes the loop work correctly even if the order of the enum is changed. +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]); Warnings should be printed with log_warning() and not printf() so that they end up on stderr, not stdout. I fixed this now in git. Thanks, for clean-ups. Much appreciated. Michal Thanks, Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 2/2] localectl: print warning when there are options given on kernel cmdline
On Wed, 24.09.14 17:18, Michal Sekletar (msekl...@redhat.com) wrote: Heya, +for (j = VARIABLE_LANG; j _VARIABLE_LC_MAX; j++) I think it is much nicer to count from an explicit 0 on here, instead of VARIABLE_LANG, since this makes the loop work correctly even if the order of the enum is changed. +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]); Warnings should be printed with log_warning() and not printf() so that they end up on stderr, not stdout. I fixed this now in git. Thanks, Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 2/2] localectl: print warning when there are options given on kernel cmdline
On Thu, Sep 25, 2014 at 04:47:58AM +0200, Zbigniew Jędrzejewski-Szmek wrote: On Wed, Sep 24, 2014 at 05:18:47PM +0200, Michal Sekletar wrote: --- src/core/locale-setup.c | 47 + src/locale/localectl.c | 50 src/shared/locale-util.c | 20 +++ src/shared/locale-util.h | 25 4 files changed, 100 insertions(+), 42 deletions(-) Both patches look good. Please push. Pushed now. Michal Zbyszek diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c index 7a41035..5177dbf 100644 --- a/src/core/locale-setup.c +++ b/src/core/locale-setup.c @@ -30,48 +30,11 @@ #include fileio.h #include strv.h #include env-util.h - -enum { -/* We don't list LC_ALL here on purpose. People should be - * using LANG instead. */ - -VARIABLE_LANG, -VARIABLE_LANGUAGE, -VARIABLE_LC_CTYPE, -VARIABLE_LC_NUMERIC, -VARIABLE_LC_TIME, -VARIABLE_LC_COLLATE, -VARIABLE_LC_MONETARY, -VARIABLE_LC_MESSAGES, -VARIABLE_LC_PAPER, -VARIABLE_LC_NAME, -VARIABLE_LC_ADDRESS, -VARIABLE_LC_TELEPHONE, -VARIABLE_LC_MEASUREMENT, -VARIABLE_LC_IDENTIFICATION, -_VARIABLE_MAX -}; - -static const char * const variable_names[_VARIABLE_MAX] = { -[VARIABLE_LANG] = LANG, -[VARIABLE_LANGUAGE] = LANGUAGE, -[VARIABLE_LC_CTYPE] = LC_CTYPE, -[VARIABLE_LC_NUMERIC] = LC_NUMERIC, -[VARIABLE_LC_TIME] = LC_TIME, -[VARIABLE_LC_COLLATE] = LC_COLLATE, -[VARIABLE_LC_MONETARY] = LC_MONETARY, -[VARIABLE_LC_MESSAGES] = LC_MESSAGES, -[VARIABLE_LC_PAPER] = LC_PAPER, -[VARIABLE_LC_NAME] = LC_NAME, -[VARIABLE_LC_ADDRESS] = LC_ADDRESS, -[VARIABLE_LC_TELEPHONE] = LC_TELEPHONE, -[VARIABLE_LC_MEASUREMENT] = LC_MEASUREMENT, -[VARIABLE_LC_IDENTIFICATION] = LC_IDENTIFICATION -}; +#include locale-util.h int locale_setup(char ***environment) { char **add; -char *variables[_VARIABLE_MAX] = {}; +char *variables[_VARIABLE_LC_MAX] = {}; int r = 0, i; if (detect_container(NULL) = 0) { @@ -121,13 +84,13 @@ int locale_setup(char ***environment) { } add = NULL; -for (i = 0; i _VARIABLE_MAX; i++) { +for (i = 0; i _VARIABLE_LC_MAX; i++) { char *s; if (!variables[i]) continue; -s = strjoin(variable_names[i], =, variables[i], NULL); +s = strjoin(locale_variable_to_string(i), =, variables[i], NULL); if (!s) { r = -ENOMEM; goto finish; @@ -157,7 +120,7 @@ int locale_setup(char ***environment) { finish: strv_free(add); -for (i = 0; i _VARIABLE_MAX; i++) +for (i = 0; i _VARIABLE_LC_MAX; i++) free(variables[i]); return r; diff --git a/src/locale/localectl.c b/src/locale/localectl.c index bf8b7b2..5917364 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,
Re: [systemd-devel] [PATCH 2/2] localectl: print warning when there are options given on kernel cmdline
On Wed, Sep 24, 2014 at 05:18:47PM +0200, Michal Sekletar wrote: --- src/core/locale-setup.c | 47 + src/locale/localectl.c | 50 src/shared/locale-util.c | 20 +++ src/shared/locale-util.h | 25 4 files changed, 100 insertions(+), 42 deletions(-) Both patches look good. Please push. Zbyszek diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c index 7a41035..5177dbf 100644 --- a/src/core/locale-setup.c +++ b/src/core/locale-setup.c @@ -30,48 +30,11 @@ #include fileio.h #include strv.h #include env-util.h - -enum { -/* We don't list LC_ALL here on purpose. People should be - * using LANG instead. */ - -VARIABLE_LANG, -VARIABLE_LANGUAGE, -VARIABLE_LC_CTYPE, -VARIABLE_LC_NUMERIC, -VARIABLE_LC_TIME, -VARIABLE_LC_COLLATE, -VARIABLE_LC_MONETARY, -VARIABLE_LC_MESSAGES, -VARIABLE_LC_PAPER, -VARIABLE_LC_NAME, -VARIABLE_LC_ADDRESS, -VARIABLE_LC_TELEPHONE, -VARIABLE_LC_MEASUREMENT, -VARIABLE_LC_IDENTIFICATION, -_VARIABLE_MAX -}; - -static const char * const variable_names[_VARIABLE_MAX] = { -[VARIABLE_LANG] = LANG, -[VARIABLE_LANGUAGE] = LANGUAGE, -[VARIABLE_LC_CTYPE] = LC_CTYPE, -[VARIABLE_LC_NUMERIC] = LC_NUMERIC, -[VARIABLE_LC_TIME] = LC_TIME, -[VARIABLE_LC_COLLATE] = LC_COLLATE, -[VARIABLE_LC_MONETARY] = LC_MONETARY, -[VARIABLE_LC_MESSAGES] = LC_MESSAGES, -[VARIABLE_LC_PAPER] = LC_PAPER, -[VARIABLE_LC_NAME] = LC_NAME, -[VARIABLE_LC_ADDRESS] = LC_ADDRESS, -[VARIABLE_LC_TELEPHONE] = LC_TELEPHONE, -[VARIABLE_LC_MEASUREMENT] = LC_MEASUREMENT, -[VARIABLE_LC_IDENTIFICATION] = LC_IDENTIFICATION -}; +#include locale-util.h int locale_setup(char ***environment) { char **add; -char *variables[_VARIABLE_MAX] = {}; +char *variables[_VARIABLE_LC_MAX] = {}; int r = 0, i; if (detect_container(NULL) = 0) { @@ -121,13 +84,13 @@ int locale_setup(char ***environment) { } add = NULL; -for (i = 0; i _VARIABLE_MAX; i++) { +for (i = 0; i _VARIABLE_LC_MAX; i++) { char *s; if (!variables[i]) continue; -s = strjoin(variable_names[i], =, variables[i], NULL); +s = strjoin(locale_variable_to_string(i), =, variables[i], NULL); if (!s) { r = -ENOMEM; goto finish; @@ -157,7 +120,7 @@ int locale_setup(char ***environment) { finish: strv_free(add); -for (i = 0; i _VARIABLE_MAX; i++) +for (i = 0; i _VARIABLE_LC_MAX; i++) free(variables[i]); return r; diff --git a/src/locale/localectl.c b/src/locale/localectl.c index bf8b7b2..5917364 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], +