summaryrefslogtreecommitdiff
path: root/src/locale
diff options
context:
space:
mode:
authorMichal Sekletar <msekleta@redhat.com>2014-09-24 13:17:43 +0200
committerMichal Sekletar <msekleta@redhat.com>2014-09-25 09:19:56 +0200
commita34286684ebb78dd3db0d7f34feb2c121c9d00cc (patch)
treef94a3b5256d39af5b5a342a15ad8b9f44deeb2ce /src/locale
parenta5f6c30da3ac58081108221bf8a0f6f1d84b33a9 (diff)
localectl: print warning when there are options given on kernel cmdline
Diffstat (limited to 'src/locale')
-rw-r--r--src/locale/localectl.c50
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: