[File] [PATCH] Magdir/linux for GRUB keyboard *.GKB

Jörg Jenderek joerg.jen.der.ek at gmx.net
Wed Aug 31 20:19:11 UTC 2022


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
some days ago i installed a new Linux system on my PC.
For security reasons i wanted some complicated password with special
characters. Unfortunately this does not work out of the box for my
system with German keyboard. After a nightmare session i find that i
myself must create keyboard modules (*.GKB) for GRUB bootloader and
insert instruction inside configuration grub.cfg to use this.

When running file command (version 5.42) on such GRUB keyboard
examples i get an output like:

de.gkb: data
fr.gkb: data
it.gkb: data
nl.gkb: data
us.gkb: data

With --extension option only ??? is displayed. Furthermore with -i
option for my samples only generic application/octet-stream is shown.

GRUB is the GRand Unified Bootloader of/for GNU found on their
website. In source of GRUB there exist header file keyboard_layouts.h
and c-source keylayouts.c with needed information about file format.
That is expressed by comment lines inside Magdir/linux like:
# URL:		https://www.gnu.org/software/grub
# Reference:	https://ftp.gnu.org/gnu/grub/grub-2.06.tar.gz
#		grub-2.06/include/grub/keyboard_layouts.h
#		grub-2.06/grub-core/commands/keylayouts.c

According to that documentation samples start with 8 byte magic
string named GRUB_KEYBOARD_LAYOUTS_FILEMAGIC. Afterward the version
is stored as 4 byte integer, which is in current version value 10.
So show that version by lines like:
 0	string		GRUBLAYO		GRUB Keyboard
 !:mime			application/x-grub-keyboard
 !:ext			gkb
 >8	ulelong		!10			\b, version %u
Instead of generic mime type application/octet-stream show an user
defined one.

I am not a c programmer, but if i under stand source right afterwards
comes four keyboard layout with 160 elements, where every element has
a size of 32 bit. First comes the normal keyboard. This is followed
by the "shift" variant and so on. So i looked in variant for USA
us.gkb where low letters q and y are located. In "normal" French
keyboard at "q" position low letter a is stored. In "normal" German
keyboard at "y" position low letter z is stored. So show that non
English variants by additional lines like:
 >92	ubyte		!0x71
 >>92	ubyte		>0x40			\b, english q is %c
 >124	ubyte		!0x79
 >124	ubyte		>0x40			\b, english y is %c

After applying the above mentioned modifications by patch
file-5.42-linux-gkb.diff then all inspected GRUB examples are
described like:

de.gkb: GRUB Keyboard, english y is z
fr.gkb: GRUB Keyboard, english q is a
it.gkb: GRUB Keyboard
nl.gkb: GRUB Keyboard
us.gkb: GRUB Keyboard

I hope my diff file can be applied in future version of file utility.

With best wishes
Jörg Jenderek
- --
Jörg Jenderek
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCYw/CPwAKCRCv8rHJQhrU
1mS4AJ93RxPTc5mfadxL+UBtR8b6IAsA4ACeM9DADGg05P4XZxf0idYHn3nt1Ck=
=xG3R
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.42/magic/Magdir/linux.old	2022-04-11 15:07:12.000000000 +0200
+++ file-5.42/magic/Magdir/linux	2022-08-31 22:15:48.139662400 +0200
@@ -535,3 +535,24 @@
 >&0		regex		[0-9]+\\.[0-9]+	\b, version %s
 >>&0		string		;
 >>>&0		regex		[A-Z0-9]+	\b, encryption %s
+
+# From:		Joerg Jenderek
+# URL:		https://www.gnu.org/software/grub
+# Reference:	https://ftp.gnu.org/gnu/grub/grub-2.06.tar.gz
+#		grub-2.06/include/grub/keyboard_layouts.h 
+#		grub-2.06/grub-core/commands/keylayouts.c
+# GRUB_KEYBOARD_LAYOUTS_FILEMAGIC
+0	string		GRUBLAYO		GRUB Keyboard
+!:mime			application/x-grub-keyboard
+!:ext			gkb
+# GRUB_KEYBOARD_LAYOUTS_VERSION like: 10
+>8	ulelong		!10			\b, version %u
+# 4 grub_uint32_t grub_keyboard_layout[160]
+# for normal french keyboard this is letter a
+>92	ubyte		!0x71
+>>92	ubyte		>0x40			\b, english q is %c
+#>732	ubyte		x			\b, english Q is %c
+# for normal german keyboard this is letter z
+>124	ubyte		!0x79
+>>124	ubyte		>0x40			\b, english y is %c
+#>764	ubyte		x			\b, english Y is %c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.42-linux-gkb.diff.sig
Type: application/octet-stream
Size: 709 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220831/37156a5e/attachment.obj>


More information about the File mailing list