Skip to content

fix: create ssh directory if it doesn't already exist when running coder config-ssh #17711

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: properly check file perms
  • Loading branch information
brettkolodny committed May 7, 2025
commit 49e5e75d79fecc260e1b1a6e4c1e6ffeb53efff9
2 changes: 1 addition & 1 deletion cli/configssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func (r *RootCmd) configSSH() *serpent.Command {

if !bytes.Equal(configRaw, configModified) {
sshDir := filepath.Dir(sshConfigFile)
if err := os.MkdirAll(sshDir, os.ModePerm); err != nil {
if err := os.MkdirAll(sshDir, 0700); err != nil {
return xerrors.Errorf("failed to create directory %q: %w", sshDir, err)
}

Expand Down
2 changes: 1 addition & 1 deletion cli/configssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func TestConfigSSH_MissingDirectory(t *testing.T) {
// Check that the directory has proper permissions (0700)
sshDirInfo, err := os.Stat(sshDir)
require.NoError(t, err)
require.Equal(t, os.ModePerm, sshDirInfo.Mode().Perm(), "directory should have 0700 permissions")
require.Equal(t, os.FileMode(0700), sshDirInfo.Mode().Perm(), "directory should have 0700 permissions")
}

func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
Expand Down
Loading