Skip to content

Run entrypoint as root so it can access /.fly/api for OIDC token#11658

Merged
nbudin merged 1 commit into
mainfrom
fix-oidc-entrypoint-root-privilege
Jun 9, 2026
Merged

Run entrypoint as root so it can access /.fly/api for OIDC token#11658
nbudin merged 1 commit into
mainfrom
fix-oidc-entrypoint-root-privilege

Conversation

@nbudin

@nbudin nbudin commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Purpose

Two problems, fixed together in this PR:

Problem 1: www user can't access /.fly/api
The previous PR (#11655) fixed the error message, which confirmed the root cause: the Unix socket is owned by root, and the container was running as www. USER www is removed from the Dockerfile before ENTRYPOINT so the script starts as root and can reach the socket. After fetching the OIDC token it drops to www via su --preserve-environment, and chowns the token file to www first so chamber can read it.

Problem 2: Fly's OIDC endpoint returns a raw JWT, not {"token":"..."} JSON
The Python one-liner was doing json.load(sys.stdin)['token'] expecting a JSON object, but the endpoint returns the bare token string. Python failed with JSONDecodeError. The fix tries JSON-parse first and falls back to using the raw response as the token value, so it works with either format.

🤖 Generated with Claude Code

The www user (set by USER in the Dockerfile) can't access the /.fly/api
Unix socket, which is owned by root. This caused the curl to return empty,
producing a useless JSONDecodeError instead of the actual failure reason.

Fix: remove USER www before ENTRYPOINT so the script starts as root, fetch
the OIDC token, then drop to www via `su --preserve-environment` before
exec'ing chamber or the app command. The token file is chown'd to www before
the privilege drop so chamber can read AWS_WEB_IDENTITY_TOKEN_FILE.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nbudin nbudin marked this pull request as ready for review June 9, 2026 04:12
@nbudin nbudin merged commit dd507c5 into main Jun 9, 2026
15 checks passed
@nbudin nbudin deleted the fix-oidc-entrypoint-root-privilege branch June 9, 2026 04:12
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
Overall Coverage 🟢 52.92% 🟢 52.92% ⚪ 0%

Minimum allowed coverage is 0%, this run produced 52.92%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant