Bug 32711 - Dracut try to source undefined KEYMAP from /etc/sysconfig/keyboard
Summary: Dracut try to source undefined KEYMAP from /etc/sysconfig/keyboard
Status: NEW
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 9
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia tools maintainers
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-10 18:18 CET by Raphael Gertz
Modified: 2024-01-10 22:14 CET (History)
1 user (show)

See Also:
Source RPM: dracut-057-4.mga9.src.rpm
CVE:
Status comment:


Attachments

Description Raphael Gertz 2024-01-10 18:18:17 CET
Hi,

Description of problem:
In file /etc/dracut.conf.d/50-mageia.conf we have:
i18n_vars="/etc/sysconfig/i18n:SYSFONT-FONT,SYSFONTACM-FONT_MAP,UNIMAP-FONT_UNIMAP,LANG,LC_ALL /etc/sysconfig/keyboard:KEYTABLE,KEYMAP,GRP_TOGGLE"

On my system, after running drakkeyboard and draklocale, /etc/sysconfig/keyboard contains:
KEYBOARD=fr_latin9
KEYTABLE=fr-latin9
XkbLayout=fr
XkbModel=pc104
XkbOptions=compose:rwin
XkbVariant=latin9

And /etc/sysconfig/i18n contains:
COUNTRY=FR
LANG=fr_FR.UTF-8
LANGUAGE=fr_FR.UTF-8:fr
LC_ADDRESS=fr_FR.UTF-8
LC_COLLATE=fr_FR.UTF-8
LC_CTYPE=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_MESSAGES=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
SYSFONT=lat0-16

But /etc/vconsole.conf contains:
FONT=lat0-16
KEYMAP=fr-latin1

or on my other system:
FONT=lat0-16
KEYMAP=fr-latin9
XKBLAYOUT=fr
XKBMODEL=pc105
XKBOPTIONS=terminate:ctrl_alt_bksp
XKBVARIANT=latin9

When I generate an initrd (with systemd included), the service systemd-vconsole-setup.service fails on loadkeys invocation because the KEYMAP file was never included.

It comes from /etc/dracut.conf.d/50-mageia.conf which try to get KEYMAP from /etc/sysconfig/keyboard where it's not defined and thus don't include the keymap file...

As stated in /usr/lib/dracut/modules.d/10i18n/README, the minimum is FONT and KEYMAP, both defined in /etc/vconsole.conf

I see few ways to fix it in /etc/dracut.conf.d/50-mageia.conf

First one is to map KEYTABLE defined in /etc/sysconfig/keyboard to KEYMAP:
i18n_vars="/etc/sysconfig/i18n:SYSFONT-FONT,SYSFONTACM-FONT_MAP,UNIMAP-FONT_UNIMAP,LANG,LC_ALL /etc/sysconfig/keyboard:KEYTABLE-KEYMAP,GRP_TOGGLE"

Or simply extract FONT and keymap from /etc/vconsole.conf:
i18n_vars="/etc/vconsole.conf:FONT,KEYMAP"

Or load minimum from /etc/vconsole and try to load the rest where available:
i18n_vars="/etc/vconsole.conf:FONT,KEYMAP /etc/locale.conf:LANG /etc/sysconfig/i18n:SYSFONT-FONT,SYSFONTACM-FONT_MAP,UNIMAP-FONT_UNIMAP,LANG,LC_ALL /etc/sysconfig/keyboard:KEYTABLE,KEYMAP,GRP_TOGGLE"

In my opinion, at this early stage, we only really require keymap to type luks password without mind-mapping to querty or have keyboard set in rescue shell.
Font seems usefull only for cosmetic reason.

I didn't look the usefullness of FONT_MAP, FONT_UNIMAP, LANG, LC_ALL and GRP_TOGGLE effect on initrd stage messages.

In my case it seems that systemd vconsole service don't use KEYTABLE when KEYMAP is undefined, it seems to load only vconsole.(keymap|keymap_toggle|font|font_map|font_unimap)

Version-Release number of selected component (if applicable):
dracut-057-4.mga9

How reproducible:
Always

Steps to Reproduce:
1. draklocale
2. drakkeyboard
3. echo 'omit_dracutmodules=" network "' > etc/dracut.conf.d/99-systemd.conf
4. mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)
5. drop to dracut rescue shell with a cmdline like rd.break=mount
6. systemctl status systemd-vconsole-setup.service
Comment 1 Raphael Gertz 2024-01-10 19:39:38 CET
It seems that it's a regression when moving to systemd because a behaviour defined in /usr/lib/dracut/modules.d/10i18n/README is not valid anymore with systemd vconsole service:
« KEYTABLE - base name for keyboard translation table; if UNICODE is true, Unicode version will be loaded. Overrides KEYMAP. »

I am unsure if it's possible to try to load the same variable from various files in i18n_vars definition and which one is elected in case of diverging duplicate definition

I am unsure how to makes sure dracut include i18n stuff, on a chroot install, it include nothing.

I am sure to have experienced the bug where systemd vconsole service fails because keymap is not included in initrd.

It was both time with a fr locale and keyboard with a luks encrypted /
Comment 2 Raphael Gertz 2024-01-10 20:45:19 CET
It seems that the problem reside with dracut, the i18n_vars do not set the configuration of /etc/vconsole.conf and /etc/locale.conf inside the initrd.

It will only serve to include the keymap and font files plus maybe files related to other variables.
Comment 3 Raphael Gertz 2024-01-10 20:57:32 CET
I replayed generating a host only initrd in various configuration:

Without change to /etc/dracut.conf.d/50-mageia.conf and no extra config in /etc/dracut.conf.d with a fr-latin9 configured keyboard, country to FR and lang to fr_FR.UTF-8, I get:

# DRACUT_SKIP_FORCED_NON_HOSTONLY=1 mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)

# cat /tmp/dracut.*/initramfs/etc/vconsole.conf 
KEYMAP="fr-latin9.uni"
EXT_KEYMAPS="  "
UNICODE="1"
FONT="lat0-16"

# cat /tmp/dracut.*/initramfs/etc/locale.conf   
LANG="fr_FR.UTF-8"

# tree /tmp/dracut.*/initramfs/usr/lib/kbd                
/tmp/dracut.SW9dIY/initramfs/usr/lib/kbd
└── consolefonts
    ├── eurlatgr.psfu
    └── lat0-16.psfu

It will fail to loadkeys fr later in the boot process.


With omit_dracutmodules=" network ":

# tree /tmp/dracut.*/initramfs/usr/lib/kbd 
/tmp/dracut.EkNcyt/initramfs/usr/lib/kbd
└── consolefonts
    ├── eurlatgr.psfu
    └── lat0-16.psfu

Same result it will fail to load the required fr-latin9 keymap.


With omit_dracutmodules=" network " + i18n_vars="/etc/vconsole.conf:FONT,KEYMAP /etc/locale.conf:LANG":

# tree /tmp/dracut.*/initramfs/usr/lib/kbd                                                                   
/tmp/dracut.nrK4Ey/initramfs/usr/lib/kbd
├── consolefonts
│   ├── eurlatgr.psfu
│   └── lat0-16.psfu
└── keymaps
    └── i386
        └── azerty
            └── fr-latin9.map

Not sure it has ever worked in the first place, we may want to replace i18n_vars to this value in /etc/dracut.conf.d/50-mageia.conf
Comment 4 Raphael Gertz 2024-01-10 21:07:30 CET
In summary, i18n_vars is not used to set the configuration inside the initrd, but only as /etc/vconsole.conf and /etc/locale.conf are included as is.

It seems smart to change /etc/dracut.conf.d/50-mageia.conf to i18n_vars="/etc/vconsole.conf:FONT,KEYMAP /etc/locale.conf:LANG" to makes keymap load succeed.
Comment 5 Dave Hodgins 2024-01-10 22:14:30 CET
To get vconsole.service working on my install I changed ...
$ cat /etc/vconsole.conf 
FONT=lat0-16
FONT_UNIMAP=/usr/share/kbd/unimaps/cp437AB.uni
KEYMAP=us

The font comes from ...
$ rpm -q -f /usr/lib/kbd/consolefonts/lat0-16.psfu.gz
kbd-2.5.1-1.mga9

The unimap comes from ...
$ rpm -q -f /usr/share/kbd/unimaps/cp437AB.uni
hxtools-20221120-2.mga9

The keymap comes from ...
$ rpm -q -f /usr/lib/kbd/keymaps/i386/qwerty/us.map.gz
kbd-2.5.1-1.mga9

Assigning to the Mageia tools group as this should be configured during
installation.

CC: (none) => davidwhodgins
Assignee: bugsquad => mageiatools


Note You need to log in before you can comment on or make changes to this bug.