Skip to content
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

Fix Unix URL handling in ssh_forwarder #372

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
11 changes: 2 additions & 9 deletions pkg/sshclient/ssh_forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"net"
"net/url"
"os"
"runtime"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -111,18 +109,13 @@ func connectForward(ctx context.Context, bastion *Bastion) (CloseWriteConn, erro
}

func listenUnix(socketURI *url.URL) (net.Listener, error) {
path := socketURI.Path
if runtime.GOOS == "windows" {
path = strings.TrimPrefix(path, "/")
}

if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
if err := os.Remove(socketURI.Path); err != nil && !os.IsNotExist(err) {
return nil, err
}

oldmask := fs.Umask(0177)
defer fs.Umask(oldmask)
listener, err := net.Listen("unix", path)
listener, err := net.Listen("unix", socketURI.Path)
if err != nil {
return listener, errors.Wrapf(err, "Error listening on socket: %s", socketURI.Path)
}
Expand Down
Loading