Repository navigation
fix(oauth): detect Podman containers via /run/.containerenv - #4008
Open
leninworld wants to merge 1 commit into
Open
leninworld wants to merge 1 commit into
leninworld wants to merge 1 commit into
Conversation
Podman creates /run/.containerenv instead of /.dockerenv, and with cgroup v2 /proc/1/cgroup is just "0::/", so the server treated a Podman run as native and bound the OAuth callback to the container's loopback, where the published callback port cannot reach it. Fixes github#4007
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change adding Podman detection to local OAuth handling.
No open issues 🎉
What changed in this PR
Fixes #4007 by detecting Podman containers so local OAuth uses the existing container-specific callback handling.
Changes:
- Recognizes
/run/.containerenvalongside existing Docker and containerd markers. - Extracts marker detection into a testable helper and clarifies its documentation.
- Adds table-driven tests for container markers and non-container cases.
| File | Description |
|---|---|
| internal/oauth/env.go | Adds Podman detection while preserving the Linux-only guard. |
| internal/oauth/env_test.go | Tests marker detection using isolated temporary directories. |
Review effort: Balanced (adaptive)
fahimfazledev-glitch
approved these changes
Dec 2, 2026
fahimfazledev-glitch
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #4007.
Summary
Under Podman the OAuth callback was bound to the container's own loopback, so the published callback port never reached it and browser login always failed. Container detection now also recognises Podman's
/run/.containerenvmarker.Why
isRunningInDocker()only checked/.dockerenvanddocker/containerdin/proc/1/cgroup. Podman creates neither: it writes/run/.containerenv, and with cgroup v2 + crun/proc/1/cgroupis just0::/. The server then treated the run as native,listenCallback()bound127.0.0.1inside the container, and every connection to the published port was reset (as the issue traces).Fixes #4007
What changed
internal/oauth/env.go:isRunningInDocker()keeps its non-Linux early return and now delegates tocontainerMarkersPresent(root), which checks the existing markers plus/run/.containerenv. Production passes/; the root parameter only makes the check testable. The doc comment now names Podman and both decisions the result drives (skipping random-port PKCE, binding the callback to all interfaces).internal/oauth/env_test.go(new): table test overt.TempDir()roots: no markers,.dockerenv,run/.containerenv, Docker cgroup, containerd cgroup, and a bare cgroup v20::/(still not a container). With the.containerenvcheck removed, the Podman case fails (expected: true, actual: false).MCP impact
Only container detection for the local OAuth login changes.
Prompts tested (tool changes only)
Security / limits
Podman runs now get the same handling Docker runs already get: a random callback port goes to device flow, and a fixed port binds all container interfaces with the existing warning to publish it to loopback only. Like
/.dockerenvtoday, the marker does not tell host-network containers (--network=host, Toolbox, Distrobox) apart from isolated ones; that is unchanged in kind and left out of this PR.Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lintRan
gofmt -sand golangci-lint v2.14.0 (the pinned version) on./...: 0 issues../script/testgo test -race ./...passes.Docs
Skills
No tools or toolset instructions change, so no bundled skill applies.