mirror of
https://github.com/linuxboot/heads.git
synced 2025-02-20 17:22:53 +00:00
initrd: work around a bug in busybox sha256sum
busybox sha256sum will create a checksum file for uncommon file names (e.g. /boot/foo"$\n"bar), but fail to verify that exact file. https://bugs.busybox.net/show_bug.cgi?id=14226 Thus disallow all files in /boot/ with strange file names at the time of signing for now. Verifying in the presence of new files with such file names in /boot/ is no issue for the kexec_tree verification due to the previously implemented escaping mechanism.
This commit is contained in:
parent
e368c3f6ea
commit
4ce8f664ad
@ -23,6 +23,8 @@ paramsdir="${paramsdir%%/}"
|
||||
|
||||
confirm_gpg_card
|
||||
|
||||
assert_signable
|
||||
|
||||
# update hashes in /boot before signing
|
||||
if [ "$update" = "y" ]; then
|
||||
(
|
||||
|
@ -558,6 +558,8 @@ if ! gpg --card-status >/dev/null 2>&1 ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
assert_signable
|
||||
|
||||
# Action time...
|
||||
|
||||
# detect and set /boot device
|
||||
|
@ -397,6 +397,24 @@ escape_zero() {
|
||||
}
|
||||
}
|
||||
|
||||
# Currently heads doesn't support signing file names with certain characters
|
||||
# due to https://bugs.busybox.net/show_bug.cgi?id=14226. Also, certain characters
|
||||
# may be intepreted by `whiptail`, `less` et al (e.g. \n, \b, ...).
|
||||
assert_signable() {
|
||||
# ensure /boot mounted
|
||||
if ! grep -q /boot /proc/mounts ; then
|
||||
mount -o ro /boot || die "Unable to mount /boot"
|
||||
fi
|
||||
|
||||
find /boot -print0 > /tmp/signable.ref
|
||||
local del='\001-\037\134\177-\377'
|
||||
LC_ALL=C tr -d "$del" < /tmp/signable.ref > /tmp/signable.del || die "Failed to execute tr."
|
||||
if ! cmp -s "/tmp/signable.ref" "/tmp/signable.del" &> /dev/null ; then
|
||||
die "Some /boot file names contain characters that are currently not supported by heads: $del"$'\n'"Please investigate!"
|
||||
fi
|
||||
rm -f /tmp/signable.*
|
||||
}
|
||||
|
||||
verify_checksums()
|
||||
{
|
||||
local boot_dir="$1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user