Fix TestHardenConfigDir on macOS: resolve TMPDIR symlinks in test dirs

Merged
JE
5mo ago
+25-13

Problem

make test (and therefore make release → release-check) fails on macOS: every positive-case subtest of TestHardenConfigDir reports the dir stayed 0755 when 0700 was expected.

On darwin, t.TempDir() lives under /var → private/var. hardenConfigDir's per-component O_NOFOLLOW descent correctly refuses the symlinked ancestor and silently aborts — so the positive cases never chmod, and the negative cases pass vacuously. Linux CI never sees this because its TMPDIR has no symlinked ancestors (CI is ubuntu-only across the matrix).

Fix

Route all TestHardenConfigDir temp dirs through a hardenTempDir helper that EvalSymlinks-resolves t.TempDir() — the same thing the symlinked-final-component subtest already did inline. Test-only change; no production code touched. The production feature is unaffected for real config paths (~/.config/... has no symlinked ancestors).

Testing

  • GOWORK=off go test ./internal/cli -run 'TestHardenConfigDir|TestOwnedByUID' green on macOS (previously 6 subtests failing)
  • Full GOWORK=off make test on darwin (arm64) green
  • No behavior change on Linux — the resolved path is identical there

Context

Found while prepping the v0.8.0 release (73 commits unreleased since v0.7.2; the release is wanted for the completed-todos fix in #456, T2 card BC-9988776161). This unblocks running make release from a Mac.

https://claude.ai/code/session_01CSpm1M4ZQwmurqqNb5uQx8


Summary by cubic

Fixes macOS failures in TestHardenConfigDir by resolving symlinks in temp test dirs. This makes the hardening assertions run correctly and unblocks make release on macOS.

  • Bug Fixes
    • Added hardenTempDir(t) that EvalSymlinks the result of t.TempDir() and used it across TestHardenConfigDir subtests to avoid TMPDIR symlink ancestors.
    • Test-only change; Linux behavior unchanged; make test/release-check now pass on macOS.