Repository navigation
fix(opts): reject scheme-less socket paths in DOCKER_HOST instead of treating them as TCP hosts - #7550
Open
Anuj-er wants to merge 1 commit into
Open
fix(opts): reject scheme-less socket paths in DOCKER_HOST instead of treating them as TCP hosts#7550Anuj-er wants to merge 1 commit into
Anuj-er wants to merge 1 commit into
Conversation
…treating them as TCP hosts
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.
Fixes #5846
Root cause
A scheme-less
DOCKER_HOSTvalue is unconditionally treated as a TCP host inparseDockerDaemonHost. SoDOCKER_HOST=/invalid.sock docker versionreportsCannot connect to the Docker daemon at tcp://localhost:2375/invalid.sock— a URL the user never typed, built byParseTCPAddrfrom an empty host (defaulted tolocalhost:2375) plus the path.Fix
Reject scheme-less values that look like filesystem paths before defaulting to TCP, with an error naming the bad input and the fix:
invalid host address "/invalid.sock": a socket path must use the "unix://" scheme, e.g. "unix:///invalid.sock". Only values starting with/are rejected, so all currently-valid bare forms keep working (localhost:5555,0.0.0.1:5555,:6666,[::1]:5555,localhost:5555/path). The error deliberately does not nameDOCKER_HOST, becauseParseHostis shared with the-Hflag. One fix inparseDockerDaemonHostcovers both surfaces.Tests
TestParseDockerDaemonHost:/invalid.sockand/run/docker.socknow expect the new error.TestParseHost:/invalid.sockadded to the invalid cases.optspackage passes;gofmtclean. Verified the new tests fail without the fix and pass with it.