|
| 1 | +# compose2pod 0.4.1 — non-root images can read the owned `/etc/hosts` |
| 2 | + |
| 3 | +A focused fix for the owned-`/etc/hosts` mechanism 0.4.0 introduced: the |
| 4 | +generated hosts file was created `0600`, so a service image that runs as a |
| 5 | +**non-root** user could not read it, and pod-internal name resolution silently |
| 6 | +failed. This restores resolution for every image regardless of its `USER`. |
| 7 | + |
| 8 | +## Fix |
| 9 | + |
| 10 | +- **World-readable owned `/etc/hosts`.** The script writes the hosts file to a |
| 11 | + `mktemp` path, which `mktemp` creates mode `0600`, owned by the invoking user. |
| 12 | + Bind-mounted read-only as `/etc/hosts` into every container, a process running |
| 13 | + as a non-root user could not read it — glibc then skips `/etc/hosts`, falls |
| 14 | + through to DNS, and every lookup fails with `could not translate host name |
| 15 | + "<svc>": Temporary failure in name resolution`, deep inside an otherwise |
| 16 | + healthy service. The script now `chmod 644`s the file right after writing it |
| 17 | + and before the first `podman run` mounts it. The file holds only |
| 18 | + `hostname → 127.0.0.1` and `extra_hosts` (`hostname → ip`) lines — nothing |
| 19 | + secret — so world-readable is correct; `umask` cannot substitute, as `mktemp` |
| 20 | + forces `0600`. Reproduced and fixed against real Podman 5.8.1: a non-root pod |
| 21 | + member goes from `/etc/hosts: Permission denied` to resolving its peers. |
| 22 | + |
| 23 | +## Why |
| 24 | + |
| 25 | +0.4.0 traded Podman's managed `/etc/hosts` (world-readable `0644`) for a |
| 26 | +script-owned file, closing the pre-6.0.0 stop-wipe bug — but the `mktemp` |
| 27 | +default mode reintroduced a resolution failure on the axis the earlier work |
| 28 | +never exercised: every 0.4.0 validation ran its containers as root. Any image |
| 29 | +with a `USER` directive (the common case in CI) hit the regression on first |
| 30 | +run. |
| 31 | + |
| 32 | +## Downstream |
| 33 | + |
| 34 | +- **No action needed.** Regenerate nothing beyond re-running compose2pod at |
| 35 | + 0.4.1 (the fix is in the emitted script, not the compose input). Compose files |
| 36 | + that lost name resolution under 0.4.0 on non-root images now work unchanged. |
| 37 | + Root-user images were never affected and are unchanged. |
| 38 | + |
| 39 | +## Internals |
| 40 | + |
| 41 | +- Tests at 100% line coverage (enforced); `ruff select=ALL`, `ty`, `eof-fixer` |
| 42 | + clean; conformance (real Docker CLI) and integration (real Podman) harnesses |
| 43 | + green. The fix was reproduced end-to-end on Podman 5.8.1 via |
| 44 | + `quay.io/podman/stable:v5.8.1`: without the `chmod` a `--user 1000` member |
| 45 | + fails to read `/etc/hosts`; with it, it resolves `db → 127.0.0.1`. |
| 46 | +- **`require_string_keys` returns the validated keys as `set[str]`.** ty 0.0.62 |
| 47 | + tightened `sorted()`'s bound, rejecting the 11 `sorted(set(mapping) - KNOWN)` |
| 48 | + unsupported-key error paths (an untyped mapping infers `set[object]`, which is |
| 49 | + not sortable). The shared key-string check now returns the keys it validated, |
| 50 | + so each check consumes a statically sortable `set[str]` and drops a redundant |
| 51 | + re-iteration. No behavior change. |
0 commit comments