Never leave XKBMODEL unset in /etc/default/keyboard

Andreas Henriksson andreas at fatal.se
Mon Feb 22 13:54:34 GMT 2016


Closes: #815154
---
 src/locale/localed.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/locale/localed.c b/src/locale/localed.c
index 236fba7..e9b1a23 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -408,6 +408,7 @@ static int vconsole_write_data(Context *c) {
 static int x11_write_data(Context *c) {
         int r;
         char *t, **u, **l = NULL;
+        char *xkbmodel;
 
         r = load_env_file(NULL, "/etc/default/keyboard", NULL, &l);
         if (r < 0 && r != -ENOENT)
@@ -434,23 +435,30 @@ static int x11_write_data(Context *c) {
                 l = u;
         }
 
+        /* Note: Always output default "XKBMODEL=pc105" for compatibility.
+         * Some programs expect the variable to always be around and
+         * console-setup maintainer says it should be.
+         * See http://bugs.debian.org/815154
+         */
         if (isempty(c->x11_model)) {
-                l = strv_env_unset(l, "XKBMODEL");
+                xkbmodel = "pc105";
         } else {
-                if (asprintf(&t, "XKBMODEL=%s", c->x11_model) < 0) {
-                        strv_free(l);
-                        return -ENOMEM;
-                }
+                xkbmodel = c->x11_model;
+        }
 
-                u = strv_env_set(l, t);
-                free(t);
+        if (asprintf(&t, "XKBMODEL=%s", xkbmodel) < 0) {
                 strv_free(l);
+                return -ENOMEM;
+        }
 
-                if (!u)
-                        return -ENOMEM;
+        u = strv_env_set(l, t);
+        free(t);
+        strv_free(l);
 
-                l = u;
-        }
+        if (!u)
+                return -ENOMEM;
+
+        l = u;
 
         if (isempty(c->x11_variant)) {
                 l = strv_env_unset(l, "XKBVARIANT");



More information about the Pkg-systemd-maintainers mailing list