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
14 changes: 14 additions & 0 deletions tests/install-phone
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions tools/install-phone
Original file line number Diff line number Diff line change
Expand Up @@ -563,22 +563,25 @@ 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 <<EOF || true
${mkdirs}rm /etc/omamobile/firstboot.conf
write $conf_file /etc/omamobile/firstboot.conf
write $(dq "$conf_file") /etc/omamobile/firstboot.conf
sif /etc/omamobile/firstboot.conf mode 0100600
sif /etc/omamobile/firstboot.conf uid 0
sif /etc/omamobile/firstboot.conf gid 0
rm /etc/omamobile/boot-update.conf
write $boot_conf /etc/omamobile/boot-update.conf
write $(dq "$boot_conf") /etc/omamobile/boot-update.conf
sif /etc/omamobile/boot-update.conf mode 0100644
sif /etc/omamobile/boot-update.conf uid 0
sif /etc/omamobile/boot-update.conf gid 0
sif /root/.ssh mode 040700
sif /root/.ssh uid 0
sif /root/.ssh gid 0
rm /root/.ssh/authorized_keys
write $keys_file /root/.ssh/authorized_keys
write $(dq "$keys_file") /root/.ssh/authorized_keys
sif /root/.ssh/authorized_keys mode 0100600
sif /root/.ssh/authorized_keys uid 0
sif /root/.ssh/authorized_keys gid 0
Expand Down