Skip to content

Commit

Permalink
Fix Unix URL handling in ssh_forwarder
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Sengileyev <[email protected]>
  • Loading branch information
arixmkii committed Jul 19, 2024
1 parent 6dbbe08 commit 459bfdc
Showing 1 changed file with 2 additions and 9 deletions.
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

0 comments on commit 459bfdc

Please sign in to comment.