pcrlock: handle piped PE input

When lock-pe or lock-uki read from stdin,
copy non-regular input to a seekable temporary fd before hashing it.

Fixes #42893.
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
This commit is contained in:
dongshengyuan
2026-07-09 11:02:46 +02:00
committed by Lennart Poettering
parent 4839cb914e
commit 8cbae52fc9
2 changed files with 82 additions and 17 deletions
+11 -4
View File
@@ -104,10 +104,17 @@ SYSTEMD_COLORS=256 "$SD_PCRLOCK"
SD_STUB="$(find /usr/lib/systemd/boot/efi/ -name "systemd-boot*.efi" | head -n1)"
if [[ -n "$SD_STUB" ]]; then
"$SD_PCRLOCK" lock-pe "$SD_STUB"
"$SD_PCRLOCK" lock-pe <"$SD_STUB"
"$SD_PCRLOCK" lock-uki "$SD_STUB"
"$SD_PCRLOCK" lock-uki <"$SD_STUB"
pe_direct="$("$SD_PCRLOCK" lock-pe "$SD_STUB")"
pe_stdin="$("$SD_PCRLOCK" lock-pe <"$SD_STUB")"
pe_pipe="$(cat "$SD_STUB" | "$SD_PCRLOCK" lock-pe)"
[[ "$pe_direct" == "$pe_stdin" ]]
[[ "$pe_stdin" == "$pe_pipe" ]]
uki_direct="$("$SD_PCRLOCK" lock-uki "$SD_STUB")"
uki_stdin="$("$SD_PCRLOCK" lock-uki <"$SD_STUB")"
uki_pipe="$(cat "$SD_STUB" | "$SD_PCRLOCK" lock-uki)"
[[ "$uki_direct" == "$uki_stdin" ]]
[[ "$uki_stdin" == "$uki_pipe" ]]
fi
PIN=huhu "$SD_PCRLOCK" make-policy --pcr="$PCRS" --recovery-pin=query