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: Start SFTP sessions in user home (working directory)#4420

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

Closed
mafredri wants to merge3 commits intomainfrommafredri/agent-sftp-dir

Conversation

mafredri
Copy link
Member

This is a simple fix for#3620 by changing the working directory of
coder agent at runtime.

Since the agent doesn't write files to it's working directory, I can't
think of any downsides to this method. It does not, however, exclude
that we rewrite the SFTP implementation to use the modernized
RequestServer sometime in the future.

Opted to place this in agent init vscli/agent because of portability
of fix, tests don't usually usecli/agent.

Fixes#3620

This is a simple fix for#3620 by changing the working directory of`coder agent` at runtime.Since the agent doesn't write files to it's working directory, I can'tthink of any downsides to this method. It does not, however, excludethat we rewrite the SFTP implementation to use the modernized`RequestServer` sometime in the future.Opted to place this in agent init vs `cli/agent` because of portabilityof fix, tests don't usually use `cli/agent`.Fixes#3620
@mafredrimafredri self-assigned thisOct 7, 2022
@mafredrimafredri requested a review froma teamOctober 7, 2022 16:51
Copy link
Member

@deansheatherdeansheather left a comment
edited
Loading

Choose a reason for hiding this comment

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

Is this the only way to solve this problem? Can we not tell the sftp module to use a certain starting directory instead?

Programs changing working directory by themselves causes relative paths (if they're ever used) to break

@mafredri
Copy link
MemberAuthor

Is this the only way to solve this problem? Can we not tell the sftp module to use a certain starting directory instead?

Programs changing working directory by themselves causes relative paths (if they're ever used) to break

Yeah, the alternative is discussed in#3620. But like Kyle mentions it's a quite involved. This would allow us to fix it immediately whereas if we go the alternative approach not sure when we'd get around to it.

Are there any relative paths used by the agent? I for one can't find any. The only file we write (to my knowledge) is a log file and that one is opened earlier and uses an absolute path.

@mafredri
Copy link
MemberAuthor

@deansheather thinking about this some more, I failed to consider the effect this will have on tests. Even if nothing breaks today, there's bound to be some breakage (e.g. looking uptestdata/) down the line.

Because of that, I would consider:

  1. Moving thiscli/agent.go, disabling the chdir in test-mode and adding a hidden test flag to enable it for one particular test running the agent as a separate command
  2. Forking the sftp package and adding adding a flag for changing the initial directory (have not validated the how plausible this is)

@deansheather
Copy link
Member

We could also contribute it upstream

mafredri added a commit that referenced this pull requestOct 14, 2022
This commit switches to our fork of `pkg/sftp` which includes a Serveroption for changing the current working directory.Attempt to upstream:pkg/sftp#528Supercedes andcloses#4420Fixes#3620
@mafredrimafredri deleted the mafredri/agent-sftp-dir branchOctober 14, 2022 10:49
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 14, 2022
mafredri added a commit that referenced this pull requestOct 14, 2022
This commit switches to our fork of `pkg/sftp` which includes a Serveroption for changing the current working directory.Attempt to upstream:pkg/sftp#528Supercedes andcloses#4420Fixes#3620
kylecarbs pushed a commit that referenced this pull requestOct 21, 2022
* fix: Start SFTP sessions in user home (working directory)This commit switches to our fork of `pkg/sftp` which includes a Serveroption for changing the current working directory.Attempt to upstream:pkg/sftp#528Supercedes andcloses#4420Fixes#3620* Update fork
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@deansheatherdeansheatherdeansheather approved these changes

Assignees

@mafredrimafredri

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

SFTP sessions start in/tmp/coder.KnYnxH (instead of$HOME)
2 participants
@mafredri@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp