Files
hermes-agent/docker
Maciej Lisiewski 3ceb0def62 fix(docker): seed auth.json owner-only from the first instant (#155396)
* fix(docker): seed auth.json owner-only from the first instant

The HERMES_AUTH_JSON_BOOTSTRAP seed wrote the refresh-token session via
a bare root-context redirect, so the file landed 0644 under the ambient
umask on host-shared mounts until the chmod caught up — and that chmod
was unsilenced, so under `set -eu` a failing one aborted the boot with
the credential stranded world-readable (#126950).

Mirror the .env seed's pattern: wrap the write in `umask 077` so the
file is 0600 at the instant it exists, and downgrade the re-tightening
chmod to warn-and-continue. The rebootstrap path is untouched (it edits
an existing file as the hermes user, never creates one).

* test(docker): exercise the auth.json seed instead of regexing it

Replace the salvaged source-pattern assertions with behaviour tests that
run the real seed block under set -eu and umask 022: the write alone must
yield 0600 (chmod stubbed to a no-op), and a failing chmod must warn and
let boot continue.

Fixes #126950

* fix(docker): seed the first-boot .env owner-only too

The .env copy runs under the ambient 022 umask, so it landed 0644 and then
received the generated API_SERVER_KEY; only a best-effort chmod 600 later
tightened it. Seed it under umask 077 like auth.json.

Refs #126950

* fix(docker): don't abort boot on a failing gateway_state.json chmod

The HERMES_GATEWAY_BOOTSTRAP_STATE seed ran an unguarded chmod 644 under
set -eu, so a chmod failure (e.g. on a host-shared mount) killed the hook
right after the seed write. Make it best-effort with a warning, matching
the auth.json seed.

Refs #126950

---------

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
2026-11-14 12:46:58 +01:00
..
…