scripts: the gate scripts match their lists in the shell, not through a piped grep -q under pipefail
scripts/linux-gate-policy's overlaps() piped printf into `grep -qxF` under `set -euo pipefail`.
bash line-buffers its stdout, so grep can exit at its first match while printf is still writing;
printf then ends with SIGPIPE, pipefail gives the pipeline its status, and a match reads false.
The overlap went unseen and the policy accepted a scratch directory inside the checkout:
linux_gate_policy::a_scratch_directory_may_not_overlap_a_protected_path failed so on a loaded
msi (53490 at b14260ea79) and passed alone (53581). overlaps() now matches the lists with a
`[[ ... == *...* ]]` test. scripts/linux-gate's bsdtar check had the same shape
(`tar --version | grep -q bsdtar`) and is matched the same way.
A new integration test, no_quiet_grep_under_pipefail, reads every script under scripts/ that
sets pipefail and fails on a quiet grep after a single pipe, with a unit test of its detector.
Verified: see the check job named in the landing.
This commit is contained in:
1 parent
522e3d2627
commit
1d09ff5d10
4 files changed
+114
-3
No files matched your search
+2
-1
@@ -305,7 +305,8 @@ else
|
||||
fi
|
||||
# The listed files as a pax archive (symlinks as links, mtimes to the nanosecond, as `cp -a` kept
|
||||
# them; no macOS metadata).
|
||||
if tar --version 2>/dev/null | grep -q bsdtar; then
|
||||
# Matched in the shell: under pipefail, `| grep -q` can read false on a match (SIGPIPE).
|
||||
if [[ $(tar --version 2>/dev/null) == *bsdtar* ]]; then
|
||||
tar_flags=(--no-mac-metadata --no-xattrs --no-acls --no-fflags)
|
||||
else
|
||||
tar_flags=()
|
||||
|
||||
Reference in new issue
Block a user