Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tests/install-phone-initramfs
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,18 @@ pass "an image the owner's key makes too large for its partition is refused befo
# Each step of the append that fails (a stand-in that exits 1 on that call)
# stops the install with a message, rather than flashing the ramdisk without
# the key: copying the key, cpio packing it, lz4 decompressing the shipped
# ramdisk, lz4 recompressing
# ramdisk, cpio listing it, lz4 recompressing
for step in "install 600 can't stage the owner's key" "cpio -o cpio couldn't pack the owner's key" \
"lz4 -dc lz4 couldn't decompress vendor_kernel_boot.img's ramdisk" \
"cpio -it cpio couldn't list vendor_kernel_boot.img's ramdisk" \
"lz4 -l lz4 couldn't recompress vendor_kernel_boot.img's ramdisk"; do
read -r tool arg why <<<"$step"
mkdir -p "$t/bad-$tool"
printf '#!/bin/bash\nfor a; do [[ $a == %q ]] && exit 1; done\nexec %q "$@"\n' "$arg" "$(type -P "$tool")" > "$t/bad-$tool/$tool"
chmod +x "$t/bad-$tool/$tool"
PATH=$t/bad-$tool:$PATH refused "a failing $tool $arg in the key's append" "$why"
done
pass "a failing step of the key's append (install, cpio, lz4 -dc or lz4 -l) stops the install before anything is flashed"
pass "a failing step of the key's append (install, cpio -o, lz4 -dc, cpio -it or lz4 -l) stops the install before anything is flashed"

# The ramdisk image under an AVB footer can't take the key: refused
printf 'AVB_FOOTERS="vendor_kernel_boot:0x4000000"\nAVB_ROLLBACK_INDEX=1\nAVB_SECURITY_PATCH=2026-07-05\n' >> "$BUNDLE/device.conf"
Expand Down
9 changes: 6 additions & 3 deletions tools/install-phone
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,12 @@ if [[ -n $ramdisk_image ]]; then
rm -rf "$ramdisk_dir" && mkdir -p "$ramdisk_dir"
vendor_ramdisk get "$images/$ramdisk_image.img" "$ramdisk_dir/shipped.cpio.lz4" || die "can't read the ramdisk of $ramdisk_image.img"
lz4 -dc "$ramdisk_dir/shipped.cpio.lz4" > "$ramdisk_dir/shipped.cpio" || die "lz4 couldn't decompress $ramdisk_image.img's ramdisk"
keyfiles=$(cpio -it --quiet < "$ramdisk_dir/shipped.cpio" 2>/dev/null \
| grep -cE '^(\./)?root/\.ssh/authorized_keys$' || true)
if [[ $keyfiles != 0 ]]; then
# With --quiet, cpio -it says nothing when it lists the archive; given bytes
# that aren't one, it prints a line for every offset it tries and then its
# reason, so the message carries only that last line.
listing=$(cpio -it --quiet < "$ramdisk_dir/shipped.cpio" 2> "$ramdisk_dir/cpio.err") ||
die "cpio couldn't list $ramdisk_image.img's ramdisk: $(tail -n 1 "$ramdisk_dir/cpio.err")"
if grep -qE '^(\./)?root/\.ssh/authorized_keys$' <<<"$listing"; then
note "$ramdisk_image.img's initramfs already holds SSH keys (a development build): left as built"
else
# omamobile-boot-images' commands. The hook runs under pacman's umask
Expand Down