Bug 41970 - /etc/grub.d/30_uefi-firmware does not work with zero
Summary: /etc/grub.d/30_uefi-firmware does not work with zero
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: grub-common (show other bugs)
Version: unstable
Hardware: all Linux
: P5 normal
Assignee: Николай Костригин
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-16 10:43 MSK by Ivan A. Melnikov
Modified: 2022-02-28 20:02 MSK (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan A. Melnikov 2022-02-16 10:43:01 MSK
Некоторые реализации UEFI (например, u-boot) не поддерживают ни один из OS Indicators:

# xxd /sys/firmware/efi/efivars/OsIndicationsSupported-8be4df61-93ca-11d2-aa0d-00e098032b8c
00000000: 0600 0000 0000 0000 0000 0000            ............

В этом случае 30_uefi-firmware должен, по идее, ничего не делать, однако он выдаёт ошибку и добавляет в config не рабочий menuentry:

# grub-mkconfig
[...]
### BEGIN /etc/grub.d/30_uefi-firmware ###
/etc/grub.d/30_uefi-firmware: line 34: warning: command substitution: ignored null byte in input
Adding boot menu entry for UEFI Firmware Settings ...
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
        fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###
[...]
Comment 1 Ivan A. Melnikov 2022-02-16 10:53:13 MSK
Очень странный кусок кода:

$(printf 0x%x \'"$(cat $OS_INDICATIONS | cut -b5)"\')

По всей видимости, от пытается получить младший байт переменной OsIndicationsSupported из 8be4df61-93ca-11d2-aa0d-00e098032b8c (в файлах efivars первые 4 байта заглолвок), однако получается у него совсем не это:

$ xxd test2.bin
00000000: 0600 0000 0000 0000 0000 0000            ............
$ echo  $(printf 0x%x \'"$(cat test2.bin | cut -b5)"\')
-bash: warning: command substitution: ignored null byte in input
0x27

0x27 -- это одинарная кавычка ("'").

Вообще, вместо таких сложных подстановок с пайпами можно было бы просто взять od, bash прекрасно умеет побитовые операции и с десятичными числами:

$ od -An -t u8 --read-bytes=1 --skip-bytes=4  test2.bin
                    0
$ xxd test3.bin
00000000: 0600 0000 1122 3344 5566 7788            ....."3DUfw.
$ od -An -t u8 --read-bytes=1 --skip-bytes=4  test3.bin
                   17

(да, 17 == 0x11).

Могу сделать патч.
Comment 2 Anton Farygin 2022-02-16 14:53:21 MSK
Да, давайте конечно патч.
Comment 3 Ivan A. Melnikov 2022-02-16 15:21:21 MSK
(In reply to Anton Farygin from comment #2)
> Да, давайте конечно патч.

По-моему, как-то так:

http://git.altlinux.org/people/iv/packages/?p=grub.git;a=commitdiff;h=6889ce261a7f4bfe91e8507043bad26c94f7ad75
Comment 4 Николай Костригин 2022-02-16 15:39:40 MSK
Спасибо за патч
Comment 5 Repository Robot 2022-02-28 20:02:49 MSK
grub-2.06-alt7 -> sisyphus:

 Thu Feb 24 2022 Nikolai Kostrigin <nickel@altlinux> 2.06-alt7
 - grub-efi: improve RPM filetrigger and post install script to skip all
   actions in case of being invoked at package installing stage by OS installer
   (closes: #42025)
 - 30_uefi-firmware.in: Fix for zero supported indications (closes: #41970)
 - pack 41_custom as there appear to be users of it (closes: #41832)