diff --git a/tests/install-phone-initramfs b/tests/install-phone-initramfs index 769dc3ce2..1178d00af 100755 --- a/tests/install-phone-initramfs +++ b/tests/install-phone-initramfs @@ -153,8 +153,8 @@ refused() { # why message [args]: install refused, said why, flashed nothing grep -cF -- "$2" "$t/out" >/dev/null || { cat "$t/out"; fail "says why it refuses $1"; } [[ -z $(ls -A "$t/flashed") ]] || fail "nothing is flashed when it refuses $1" } -verify_refused() { # why message: --verify-only refuses it too, and contacts no phone - refused "$1 with --verify-only" "$2" --verify-only +verify_refused() { # why message [args]: --verify-only refuses it too, and contacts no phone + refused "$1 with --verify-only" "$2" --verify-only "${@:3}" [[ ! -s $t/fastboot.log ]] || fail "--verify-only contacts no phone when it refuses $1" } # slot_b root images: the stand-in phone's slot B partitions hold those @@ -224,6 +224,19 @@ still_staged "an install refused for another phone's --serial" rm -r "$t/work" pass "--verify-only, and an install refused before the answers, leave another install's staged files in --work alone" +# A work directory that can't be created or written (as under a read-only +# home) stops with the installer's message, before the phone +if ((EUID != 0)); then + mkdir -p "$t/locked" && chmod 555 "$t/locked" + why="can't create or write to the work directory" + verify_refused "a --work that can't be created" "$why $t/locked/work (give one you can write to with --work DIR)" --work "$t/locked/work" + verify_refused "a --work that can't be written" "$why $t/locked (give one you can write to with --work DIR)" --work "$t/locked" + refused "a full install with a --work that can't be written" "$why $t/locked " --work "$t/locked" + [[ ! -s $t/fastboot.log ]] || fail "a full install with a --work that can't be written contacts no phone" + chmod 755 "$t/locked" + pass "a --work that can't be created or written stops with the installer's message, before the phone" +fi + # The hook's first run after the install: slot B already holds its images. # Slot B as the bundle's images left it (before this change) still needed # the rewrite #564 found. diff --git a/tools/install-phone b/tools/install-phone index 6b5a906e8..99f76032f 100755 --- a/tools/install-phone +++ b/tools/install-phone @@ -465,8 +465,8 @@ if [[ " $BOOT_IMAGES " == *" vendor_kernel_boot "* ]]; then ramdisk_image=vendor elif [[ " $BOOT_IMAGES " == *" vendor_boot "* ]]; then ramdisk_image=vendor_boot; fi if [[ -n $ramdisk_image ]]; then [[ -z ${avb_size[$ramdisk_image]:-} ]] || die "$conf: AVB_FOOTERS names $ramdisk_image, which carries the ramdisk: the owner's key can't be added to a signed image" - mkdir -p "$work" - verify_dir=$(mktemp -d "$work/verify.XXXXXX") + mkdir -p "$work" && verify_dir=$(mktemp -d "$work/verify.XXXXXX") || + die "can't create or write to the work directory $work (give one you can write to with --work DIR)" trap 'rm -rf "$verify_dir"' EXIT vendor_ramdisk get "$images/$ramdisk_image.img" "$verify_dir/shipped.cpio.lz4" || die "can't read the ramdisk of $ramdisk_image.img" lz4 -dc "$verify_dir/shipped.cpio.lz4" > "$verify_dir/shipped.cpio" || die "lz4 couldn't decompress $ramdisk_image.img's ramdisk"