Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Use smarter quoting for ProxyCommand in config-ssh#3755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 9 commits intomainfrommafredri/fix-coder-configssh-proxycmd-quoting
Aug 30, 2022

Conversation

mafredri
Copy link
Member

This change takes better into account how OpenSSH executes
ProxyCommands and applies quoting accordingly.

This supercedes#3664, which was reverted.

Fixes#2853


Bonus commit:

  • fix: Ensure~/.ssh directory exists

This change takes better into account how OpenSSH executes`ProxyCommand`s and applies quoting accordingly.This supercedes#3664, which was reverted.Fixes#2853
@mafredrimafredri self-assigned thisAug 30, 2022
@mafredrimafredri requested a review froma teamAugust 30, 2022 15:44
Comment on lines 530 to 547
func sshConfigExecEscape(path string) (string, error) {
// This is unlikely to ever happen, but newlines are allowed on
// certain filesystems, but cannot be used inside ssh config.
if strings.ContainsAny(path, "\n") {
return "", xerrors.Errorf("invalid path: %s", path)
}
// In the unlikely even that a path contains quotes, they must be
// escaped so that they are not interpreted as shell quotes.
if strings.Contains(path, "\"") {
path = strings.ReplaceAll(path, "\"", "\\\"")
}
// A space or a tab requires quoting, but tabs must not be escaped
// (\t) since OpenSSH interprets it as a literal \t, not a tab.
if strings.ContainsAny(path, " \t") {
path = fmt.Sprintf("\"%s\"", path)
}
return path, nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

So --- and hear me out here 😳 --- could we test this by creating a hello-world batch or shell script (platform-dependent) under a temp path that contains a space, attempting to execute/bin/bash -c '<path of thing>', and validating that it executes successfully?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't see why not, good idea! In theory, we'd want to test all the shells.. but then again, I think we're unlikely to run into that many edge cases with this unless people do really fringe stuff with their filesystems/folder structures. 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think testing/bin/sh and/orcmd.exe is all we should do tbh

@mafredrimafredriforce-pushed themafredri/fix-coder-configssh-proxycmd-quoting branch froma5ae539 to73e6a84CompareAugust 30, 2022 16:54
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

🚀

@mafredrimafredri merged commit1dc0485 intomainAug 30, 2022
@mafredrimafredri deleted the mafredri/fix-coder-configssh-proxycmd-quoting branchAugust 30, 2022 18:08
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

Assignees

@mafredrimafredri

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Windows: ssh coder.workspace not working after running coder config-ssh
2 participants
@mafredri@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp