From ba3608ab97db9a1c6c7bab8e0aab0656a95b1312 Mon Sep 17 00:00:00 2001 From: Victor Vogel Date: Wed, 11 Nov 2026 00:21:00 +0000 Subject: [PATCH] install-phone: --work can be a path with a space install-phone writes firstboot.conf, boot-update.conf and root's authorized_keys into the image copy through a debugfs command file, and named their host paths there bare. debugfs splits each command at blanks, so a --work directory with a space in its path made the writes miss, and the install stopped with "writing firstboot.conf into the image copy failed" before anything was flashed. Each of the three host paths now goes in debugfs's own double quotes, with any double quote doubled, the encoding #625 gave the image extractors; the helper stays inline because the bundle ships install alone. Tested: tests/install-phone runs a full install with --work under a directory named 'a "spaced" dir' and reads the three files back from the flashed image (fails with main's tool, passes with this one); the host's debugfs 1.47.2 reads the quoting the same in a -f command file as in -R for a space, a double quote, a backslash, an apostrophe and a tab; a release bundle's ./install with only fastboot faked completes from a spaced --work, and the three files it writes are byte-identical to a plain --work run's (the password hash line checked against the PIN). Not tested: a phone; a path with a newline. Co-Authored-By: Claude Opus 5.5 --- tests/install-phone | 14 ++++++++++++++ tools/install-phone | 9 ++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/install-phone b/tests/install-phone index edcfe8a98..a3069366f 100755 --- a/tests/install-phone +++ b/tests/install-phone @@ -182,6 +182,20 @@ e2fsck -fn "$flashed" >/dev/null 2>&1 || fail "the flashed copy of a lived-in ro [[ $(debugfs -R 'cat /root/.ssh/authorized_keys' "$flashed" 2>/dev/null) == "$(cat "$t/home/.ssh/id_ed25519.pub")" ]] || fail "the old authorized_keys is replaced" pass "a root that already has /etc/omamobile and /root/.ssh installs clean" +# debugfs splits its commands at blanks: a --work path with a space and a +# double quote in it still gets the three files into the image copy +w=$t/'a "spaced" dir'/work +install --work "$w" || { cat "$t/out"; fail "a --work path with a space and a quote installs"; } +flashed=$t/userdata.flashed +if command -v simg2img >/dev/null && [[ $(head -c4 "$flashed" | od -An -tx1 | tr -d ' ') == 3aff26ed ]]; then + simg2img "$flashed" "$t/flashed.img"; flashed=$t/flashed.img +fi +debugfs -R 'cat /etc/omamobile/firstboot.conf' "$flashed" 2>/dev/null | grep -cx 'USERNAME=alice' >/dev/null || fail "firstboot.conf from a spaced --work" +[[ $(debugfs -R 'cat /root/.ssh/authorized_keys' "$flashed" 2>/dev/null) == "$(cat "$t/home/.ssh/id_ed25519.pub")" ]] || fail "authorized_keys from a spaced --work" +[[ $(debugfs -R 'cat /etc/omamobile/boot-update.conf' "$flashed" 2>/dev/null | grep -v '^#') == AUTO_WRITE=yes ]] || fail "boot-update.conf from a spaced --work" +[[ -z $(ls "$w") ]] || fail "the spaced --work copy is removed" +pass "a --work path with a space and a quote gets the three files into the image" + refuse() { local why=$1; shift if install "$@"; then cat "$t/out"; fail "refuses $why"; fi diff --git a/tools/install-phone b/tools/install-phone index b6ed7709f..c109848a4 100755 --- a/tools/install-phone +++ b/tools/install-phone @@ -563,14 +563,17 @@ mkdirs="" for d in /etc/omamobile /root/.ssh; do debugfs -R "stat $d" "$copy" 2>/dev/null | grep -c '^Inode:' >/dev/null || mkdirs+="mkdir $d"$'\n' done +# debugfs splits its commands at blanks: a host path goes in double quotes, +# with any double quote in it doubled +dq() { printf '"%s"' "${1//\"/\"\"}"; } debugfs -w -f - "$copy" >/dev/null 2>&1 <