Repository navigation
fix: handle paths with spaces in Match exec clause of SSH config - #18266
Merged
Merged
Conversation
spikecurtis
force-pushed
the
spike/18199-path-with-spaces
branch
from
June 6, 2025 10:35
6f0ac31 to
caee378
Compare
mafredri
approved these changes
Jun 6, 2025
mafredri
left a comment
Member
There was a problem hiding this comment.
Thanks for the research and docs here. Although this is indisputably gnarly, I much prefer it to the alternative of reducing functionality. Kudos on finding this hack 👍🏻
Please note QQ in inline comment, but other than that, approved!
| // Constructing the string and then passing it to another instance of cmd.exe does this trick here. | ||
| // - OpenSSH passes the `Match exec` command to cmd.exe regardless of whether the user has a unix-like shell like | ||
| // git bash, so we don't have a `forceUnixPath` option like for the ProxyCommand which does respect the user's | ||
| // configured shell on Windows. |
Member
There was a problem hiding this comment.
Thanks for the great write-up! ❤️
QQ: Is there a chance the "default shell" that OpenSSH uses can be configured to be powershell instead of cmd.exe? And if yes, would the for loop break?
Collaborator
Author
There was a problem hiding this comment.
I've looked into this, and OpenSSH on Windows calls system, which seems to always be cmd.exe.
|
|
||
| if strings.ContainsAny(path, " ") { | ||
| // c.f. function comment for how this works. | ||
| path = fmt.Sprintf("for /f %%%%a in ('powershell.exe -Command [char]34') do @cmd.exe /c %%%%a%s%%%%a", path) //nolint:gocritic // We don't want %q here. |
Member
There was a problem hiding this comment.
💫😵💫 %%%%%%%%%%%%%%%%%%%%%%%% 💫😵💫
Collaborator
|
/cherry-pick release/2.23 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #18199
Corrects handling of paths with spaces in the
Match !execclause we use to determine whether Coder Connect is running. This is handled differently than the ProxyCommand, so we have a different escape routine, which also varies by OS.On Windows, we resort to a pretty gnarly hack, but it does work and I feel the only other option would be to reduce functionality such that we could not detect the Coder Connect state.