Skip to content

Commit 690d19c

Browse files
committed
fix(test): hand E2E evidence back to the right user under rootless Docker
The Linux E2E passes under rootless Docker, but its evidence came back unreadable, and the run ended on sha256sum failing to open the manifest it had just written. The container writes evidence as its own non-root user. restore_evidence_owner chowned that back to $(id -u) from inside the container, which is correct only because rootful Docker maps uid to uid — the mapping CI runs under, which is why this was never noticed. Rootless inverts it: container root maps to the invoking user, and every other container id maps to a subuid the user cannot read. Chowning to 1004 there produces another subuid, not the caller. Detect the daemon mode and chown to 0:0 when rootless. Rootful behaviour, and therefore CI, is unchanged. Verified locally on rootless: evidence lands owned by the invoking user with 0600 intact, sha256sum -c passes, and the suite's own mode assertions still hold. CONTRIBUTING notes that rootless is supported.
1 parent f40be50 commit 690d19c

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎CONTRIBUTING.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Platform notes:
4343
- **Linux** builds need only Docker: `pnpm build:linux` compiles inside
4444
`swift:6.1-bookworm` and emits a tarball. Chromium must be non-Snap —
4545
the runtime rejects Snap launchers before starting, by design.
46+
- **Rootless Docker works**, including the E2E: Chromium's nested namespace
47+
sandbox runs fine, and the harness detects the daemon mode so exported QA
48+
evidence comes back owned by you. Nothing binds a host port, so the suites
49+
cannot collide with other services on a shared machine.
4650
- `pnpm test:e2e:mac` opens real windows and mutates `com.headless.app` user
4751
defaults. Don't run it in a background session or on a machine where that
4852
matters.

‎apps/headless/Tests/linux-docker.sh‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@ EVIDENCE_ROOT="${HEADLESS_EVIDENCE_ROOT:-$PWD/build/qa-evidence}"
88
mkdir -p "$EVIDENCE_ROOT"
99
EVIDENCE_DIR="$(mktemp -d "$EVIDENCE_ROOT/linux.XXXXXX")"
1010
chmod 0777 "$EVIDENCE_DIR"
11+
# The container writes evidence as its own non-root user, which lands on the
12+
# host as an id this user cannot read. Which id to hand it back to depends on
13+
# how the daemon maps them: rootful Docker maps uid to uid, so the invoking
14+
# user's id is correct, while rootless maps container root to the invoking user
15+
# and every other container id to an unreadable subuid.
16+
if docker info --format '{{join .SecurityOptions ","}}' 2>/dev/null | grep -q rootless; then
17+
EVIDENCE_OWNER="0:0"
18+
else
19+
EVIDENCE_OWNER="$(id -u):$(id -g)"
20+
fi
1121
restore_evidence_owner() {
1222
docker run --rm --user root -v "$EVIDENCE_DIR:/evidence" \
13-
headless-p1-test chown -R "$(id -u):$(id -g)" /evidence >/dev/null 2>&1 || true
23+
headless-p1-test chown -R "$EVIDENCE_OWNER" /evidence >/dev/null 2>&1 || true
1424
chmod 0700 "$EVIDENCE_DIR" >/dev/null 2>&1 || true
1525
}
1626
file_mode() {

0 commit comments

Comments
 (0)