[systemd-devel] [PATCH] {locale, vconsole}-setup.c: unconditionally read config file settings

harald at redhat.com harald at redhat.com
Tue May 3 07:39:35 PDT 2011


From: Harald Hoyer <harald at redhat.com>

systemd-vconsole-setup did not process any configuration files, if it
found at least one parameter on the kernel command line.

First we should read all config file parameter settings and let them
be overwritten by kernel command line parameters afterwards.
---
 src/locale-setup.c   |   57 +++++++++++++++++++++++--------------------------
 src/vconsole-setup.c |   40 ++++++++++++++++------------------
 2 files changed, 46 insertions(+), 51 deletions(-)

diff --git a/src/locale-setup.c b/src/locale-setup.c
index d9adfa3..097ed05 100644
--- a/src/locale-setup.c
+++ b/src/locale-setup.c
@@ -69,34 +69,7 @@ int locale_setup(void) {
 
         zero(variables);
 
-        if (detect_container(NULL) <= 0)
-                if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
-#if defined(TARGET_FEDORA) || defined(TARGET_MEEGO)
-                                        "LANG",                     &variables[VARIABLE_LANG],
-#endif
-                                        "locale.LANG",              &variables[VARIABLE_LANG],
-                                        "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)) < 0) {
-
-                        if (r != -ENOENT)
-                                log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
-                }
-
-        /* Hmm, nothing set on the kernel cmd line? Then let's
-         * try /etc/locale.conf */
-        if (r <= 0 &&
-            (r = parse_env_file("/etc/locale.conf", NEWLINE,
+        if ((r = parse_env_file("/etc/locale.conf", NEWLINE,
                                "LANG",              &variables[VARIABLE_LANG],
                                "LC_CTYPE",          &variables[VARIABLE_LC_CTYPE],
                                "LC_NUMERIC",        &variables[VARIABLE_LC_NUMERIC],
@@ -212,11 +185,35 @@ int locale_setup(void) {
                                 "LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION],
                                 NULL)) < 0) {
 
-		if (r != -ENOENT)
-			log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
+                if (r != -ENOENT)
+                        log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
         }
 
 #endif
+        if (detect_container(NULL) <= 0) {
+                if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
+#if defined(TARGET_FEDORA) || defined(TARGET_MEEGO)
+                                        "LANG",                     &variables[VARIABLE_LANG],
+#endif
+                                        "locale.LANG",              &variables[VARIABLE_LANG],
+                                        "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)) < 0) {
+
+                        if (r != -ENOENT)
+                                log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
+                }
+        }
 
         if (!variables[VARIABLE_LANG]) {
                 if (!(variables[VARIABLE_LANG] = strdup("C"))) {
diff --git a/src/vconsole-setup.c b/src/vconsole-setup.c
index 60a5f14..d5f9506 100644
--- a/src/vconsole-setup.c
+++ b/src/vconsole-setup.c
@@ -212,27 +212,7 @@ again:
 
         r = 0;
 
-        if (detect_container(NULL) <= 0)
-                if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
-#if defined(TARGET_FEDORA) || defined(TARGET_MEEGO)
-                                        "SYSFONT", &vc_font,
-                                        "KEYTABLE", &vc_keymap,
-#endif
-                                        "vconsole.keymap", &vc_keymap,
-                                        "vconsole.keymap.toggle", &vc_keymap_toggle,
-                                        "vconsole.font", &vc_font,
-                                        "vconsole.font.map", &vc_font_map,
-                                        "vconsole.font.unimap", &vc_font_unimap,
-                                        NULL)) < 0) {
-
-                        if (r != -ENOENT)
-                                log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
-                }
-
-        /* Hmm, nothing set on the kernel cmd line? Then let's
-         * try /etc/vconsole.conf */
-        if (r <= 0 &&
-            (r = parse_env_file("/etc/vconsole.conf", NEWLINE,
+        if ((r = parse_env_file("/etc/vconsole.conf", NEWLINE,
                                 "KEYMAP", &vc_keymap,
                                 "KEYMAP_TOGGLE", &vc_keymap_toggle,
                                 "FONT", &vc_font,
@@ -446,6 +426,24 @@ again:
 #endif
         }
 
+        if (detect_container(NULL) <= 0) {
+                if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
+#if defined(TARGET_FEDORA) || defined(TARGET_MEEGO)
+                                        "SYSFONT", &vc_font,
+                                        "KEYTABLE", &vc_keymap,
+#endif
+                                        "vconsole.keymap", &vc_keymap,
+                                        "vconsole.keymap.toggle", &vc_keymap_toggle,
+                                        "vconsole.font", &vc_font,
+                                        "vconsole.font.map", &vc_font_map,
+                                        "vconsole.font.unimap", &vc_font_unimap,
+                                        NULL)) < 0) {
+
+                        if (r != -ENOENT)
+                                log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
+                }
+        }
+
         r = EXIT_FAILURE;
 
         if (!utf8)
-- 
1.7.3.4



More information about the systemd-devel mailing list