Repository navigation
bin/omamobile, tools, rootfs: no pipe into grep -q under pipefail - #587
Conversation
The follow-up to derekross#575, which fixed the test scripts: the same pattern in the laptop-side scripts that set pipefail. grep -q exits at the first match, a writer still writing gets SIGPIPE, and pipefail fails the pipeline (AGENTS.md section 4, Userspace). Each site now uses grep -c ... >/dev/null, which reads all its input, with the same pattern, flags and truth value. The one that loses in practice is tools/fingerprint-capture's wait loop: sed prints the whole log from the step's start, and with the end line early in a verbose kmsg stream the old check never saw it and the step ran to its timeout. The others have short writers (adb get-state, android-info.txt, 64 bytes of the TA, the keyring, the image's passwd) that fit the pipe buffer before grep exits; they change so that no script keeps the pattern. Two of them failed open: build-inside's user-account check and signing.sh's revoked-key check would have passed on a SIGPIPE. tests/grep-q-pipes now scans bin/, tools/ and rootfs/ as well, plus tools/lib (sourced by pipefail scripts), and skips comment lines. It leaves out five stage tools whose remaining hits are command strings that tools/phone-ssh runs in the phone's shell, which has no pipefail. Nothing under packages/ or initramfs/ changes. Tested: the race harness (old 0/200, new 200/200 per form; the fingerprint-capture loop old 0/100, new 100/100), tests/grep-q-pipes with an injected pipe (fails, names the line) and a commented one (passes), tools/pr-check, tests/all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y held The scan's 'packages/*/test' pathspec matched no file, so no package test was ever scanned (91 scripts). With 'packages/*/test/*' it reads 164, and found two pipes into grep -q that landed since: device-husky's speaker_protection check (derekross#453) and omamobile-waydroid's render-node check (derekross#541). Both now read the whole pipe. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thank you, Victor. I went through the ten sites one by one: each keeps its pattern, its flags ( One thing I found while feeding the scan a known failure, and it is ours as much as yours, since I missed it on #575: the pathspec So I've pushed a small commit on top with the pathspec, that husky line as For a later PR, if you like: |
|
Note 🤖 Opus 5.5 replying on behalf of Victor. Two follow-ups from this one:
|
Three checks in the new test piped into grep -q, which tests/grep-q-pipes (derekross#587) refuses under pipefail: grep -q exits early and the writer's SIGPIPE fails the pipeline. They read a count or compare the first line now; what they check is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…dresses across boots (#510) The USB gadget's two MAC addresses were random at every boot, so the laptop saw a new network card each time and its connection profile for the phone never stuck. omamobile-usb-mac.service now makes one locally administered pair on the first boot, saves it under /var/lib/omamobile, and puts the same pair on the gadget at every later boot, before the network is configured. The addresses are random, never derived from a serial number or any other identifier of the phone, and never logged. Changing the addresses means taking the gadget apart, and USB is the only link, so the step is guarded: a marker is written while the gadget is apart, anything that fails puts the gadget back together, and a boot that finds the marker (the last try hung) stands aside and leaves the kernel's temporary pair in place. Tested on a Pixel 7 Pro (7.3.0-rc6-omamobile-push1-gbcc4a92ca2e0), the addresses compared by checksum only: - first boot: a pair is made and saved; - second boot: the same pair; - a boot with the marker placed by hand: the unit stands aside, the marker is removed, the saved file is unchanged; - the next boot: the saved pair is back; - tools/phone-smoke passes, and the modem is back after every reboot. The merge also brings the branch up to main, sets the version to 0.1.49 and rewrites three test lines that piped into grep -q (tests/grep-q-pipes, #587). Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
…de fake tells arguments from stdin Review of derekross#539. tests/grep-q-pipes (derekross#587) refuses a pipe into grep -q in a script that sets pipefail: grep -q exits at the first match, the writer can get SIGPIPE, and pipefail then fails the pipeline at random. test/hotspot-panel.sh had eleven; they now use grep -c ... >/dev/null, which reads all its input. The fake qrencode logged its arguments and its stdin on one line, so the check that the WIFI: string goes to qrencode on stdin passed either way. It now writes "qrencode args:" and "qrencode stdin:" lines, and the test checks that the string arrives on stdin, that the arguments are only the options, and that the string is never an argument (it would show in /proc/*/cmdline). With the script changed to pass the string as an argument, the old test still passed and the new one fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rekross#587) * bin/omamobile, tools, rootfs: no pipe into grep -q under pipefail The follow-up to derekross#575, which fixed the test scripts: the same pattern in the laptop-side scripts that set pipefail. grep -q exits at the first match, a writer still writing gets SIGPIPE, and pipefail fails the pipeline (AGENTS.md section 4, Userspace). Each site now uses grep -c ... >/dev/null, which reads all its input, with the same pattern, flags and truth value. The one that loses in practice is tools/fingerprint-capture's wait loop: sed prints the whole log from the step's start, and with the end line early in a verbose kmsg stream the old check never saw it and the step ran to its timeout. The others have short writers (adb get-state, android-info.txt, 64 bytes of the TA, the keyring, the image's passwd) that fit the pipe buffer before grep exits; they change so that no script keeps the pattern. Two of them failed open: build-inside's user-account check and signing.sh's revoked-key check would have passed on a SIGPIPE. tests/grep-q-pipes now scans bin/, tools/ and rootfs/ as well, plus tools/lib (sourced by pipefail scripts), and skips comment lines. It leaves out five stage tools whose remaining hits are command strings that tools/phone-ssh runs in the phone's shell, which has no pipefail. Nothing under packages/ or initramfs/ changes. Tested: the race harness (old 0/200, new 200/200 per form; the fingerprint-capture loop old 0/100, new 100/100), tests/grep-q-pipes with an injected pipe (fails, names the line) and a commented one (passes), tools/pr-check, tests/all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * tests/grep-q-pipes: scan the package tests too, and the two pipes they held The scan's 'packages/*/test' pathspec matched no file, so no package test was ever scanned (91 scripts). With 'packages/*/test/*' it reads 164, and found two pipes into grep -q that landed since: device-husky's speaker_protection check (derekross#453) and omamobile-waydroid's render-node check (derekross#541). Both now read the whole pipe. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Derek Ross <derekross@gmail.com>
…dresses across boots (derekross#510) The USB gadget's two MAC addresses were random at every boot, so the laptop saw a new network card each time and its connection profile for the phone never stuck. omamobile-usb-mac.service now makes one locally administered pair on the first boot, saves it under /var/lib/omamobile, and puts the same pair on the gadget at every later boot, before the network is configured. The addresses are random, never derived from a serial number or any other identifier of the phone, and never logged. Changing the addresses means taking the gadget apart, and USB is the only link, so the step is guarded: a marker is written while the gadget is apart, anything that fails puts the gadget back together, and a boot that finds the marker (the last try hung) stands aside and leaves the kernel's temporary pair in place. Tested on a Pixel 7 Pro (7.3.0-rc6-omamobile-push1-gbcc4a92ca2e0), the addresses compared by checksum only: - first boot: a pair is made and saved; - second boot: the same pair; - a boot with the marker placed by hand: the unit stands aside, the marker is removed, the saved file is unchanged; - the next boot: the saved pair is back; - tools/phone-smoke passes, and the modem is back after every reboot. The merge also brings the branch up to main, sets the version to 0.1.49 and rewrites three test lines that piped into grep -q (tests/grep-q-pipes, derekross#587). Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
What and why
The follow-up to #575, which fixed the test scripts: the same pattern in the laptop-side scripts that set pipefail, with
bin/omamobile'sadb get-state | grep -q deviceamong them.grep -qexits at the first match, a writer that is still writing gets SIGPIPE, and pipefail fails the pipeline (AGENTS.md §4, Userspace; LESSONS L-15). Each site now usesgrep -c … >/dev/null, with the same pattern, flags and truth value (!,&&and||kept).bin/omamobile:1125,:1141(adb get-state)rootfs/build-inside:201(user-account check)dietools/extract-{fingerprint-vendor,vendor-chroot,vendor-firmware}(android-info.txt),extract-fingerprint-vendor:342(head -c 64)tools/fingerprint-capture:128(since_start)sedprints the whole log after the end line; the old check missed it 100 of 100 times on a 50k-line log, and the step ran to its timeouttools/lib/signing.sh:39,:43(trusted and revoked)Race harness, under pipefail, with a writer that prints the match and then 200k more lines, 200 runs per form (
if,&&,|| die,if !, revoked): old 0/200, new 200/200. With no match, both forms agree.tests/grep-q-pipesnow also scans pipefail scripts inbin/,tools/androotfs/, plustools/lib(sourced by pipefail scripts), and skips comment lines. A stray pipe intools/lib/signing.shortools/extract-vendor-chrootfails it and names the line.Not changed:
packages/(omamobile-boot-success×3,omamobile-usb-rescue×4,omamobile-wait-bluetooth,omamobile-remote,omamobile-keys,QuickSettings.qml, Omarchy patches 0006/0007/0022, owl-widgets): the phone-side runtime files remain unchanged; touching them would require package version bumps and a phone smoke report.packages/omamobile-device-husky/test/allandpackages/omamobile-modem/test/nv-overlayare host tests; the latter remains out until tests: intermittent Broken pipe in omamobile-modem NV-overlay tests on Omarchy #457.initramfs/init:292: it's in every boot image and safety-critical. It's busyboxsh, which has no pipefail, so it can't race.acpm-stage,aoc-stage,fingerprint-capture,husky-deadmanandwifi-w1-capturesend throughtools/phone-ssh: they run in the phone's shell, which has no pipefail. The guard leaves these five files out by path, with that reason in its comment.device/dodge/desktop/setup-stock:64: it runs on the dodge phone and its writer prints one or two lines.Device and build
uname -r): n/aChecks (no phone needed)
tools/pr-check origin/mainpassestests/allpasses (490 ok, 0 not ok)tests/packages: no package touchedversionbumped, and the new version is in the commit subject (no package changed)Co-Authored-By:orAssisted-by:trailer, never aSigned-off-by:On the phone
fingerprint-captureandbin/omamobile fastbootagainst a real phone; the race was shown with the same command shapes on the laptopuserdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)tools/phone-smokereportNot applicable: laptop-side tools only (CONTRIBUTING.md §6.5).
Generated with Claude Opus 5.5 in T3 Code Nightly