[Pkg-cryptsetup-devel] loadkeys in early userspace (using initramfs-tools)

Tim Dijkstra tim at famdijkstra.org
Tue Jan 9 15:20:37 CET 2007


Hi,

Just like cryptsetup the uswsusp package needs to interact with the
user via the keyboard in early userspace. For people with non-us
keyboards that can be problematic because loadkeys hasn't run yet.

I found out that cryptsetup already solved the problem in its
initramfs-{hook,script}. To not duplicate your work wouldn't it be
better to split that functionality of and put it in the initramfs-tools
package?

What do you think?

grts Tim

For reference, the code I'm referring to follows,

====[ In hooks/cryptroot ]=======================================================

prepare_keymap() {
        local env charmap

        # Allow the correct keymap to be loaded if possible
        if [ ! -x /bin/loadkeys ] || [ ! -r /etc/console/boottime.kmap.gz ]; then
                return 1
        fi

        copy_exec /bin/loadkeys /bin/
        cp /etc/console/boottime.kmap.gz $DESTDIR/etc/

        # Check for UTF8 console
        if [ ! -x /usr/bin/kbd_mode ]; then
                return 0
        fi

        if [ -r /etc/environment ]; then
                env="/etc/environment"
        elif [ -r /etc/default/locale ]; then
                env="/etc/default/locale"
        else
                return 0
        fi

        for var in LANG LC_ALL LC_CTYPE; do
                value=$(egrep "^[^#]*${var}=" $env | tail -n1 | cut -d= -f2)
                eval $var=$value
        done

        charmap=$(LANG=$LANG LC_ALL=$LC_ALL LC_CTYPE=$LC_CTYPE locale charmap)
        if [ "$charmap" = "UTF-8" ]; then
                copy_exec /usr/bin/kbd_mode /bin/
        fi
        return 0
}


====[ In scripts/local-top/cryptroot ]============================================

load_keymap()
{
        local opts
        opts="-q"

        # Should terminal be in UTF8 mode?
        if [ -x /bin/kbd_mode ]; then
                /bin/kbd_mode -u
                opts="$opts -u"
        fi

        # Load custom keymap
        if [ -x /bin/loadkeys -a -r /etc/boottime.kmap.gz ]; then
                loadkeys $opts /etc/boottime.kmap.gz
        fi
}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-cryptsetup-devel/attachments/20070109/367c82b9/signature.pgp


More information about the Pkg-cryptsetup-devel mailing list