Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions pkg/reversesshfs/reversesshfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ func (rsf *ReverseSSHFS) Start() error {
}
if runtime.GOOS == "windows" && path.IsAbs(rsf.LocalPath) {
logrus.Infof("Accepting %q Unix path, assuming Cygwin/msys2 OpenSSH", rsf.LocalPath)
// Convert MSYS2 path to Windows native path
rsf.LocalPath = convertMSYS2Path(rsf.LocalPath)
logrus.Infof("Converted path for native Windows OpenSSH: %q", rsf.LocalPath)
}

if !path.IsAbs(rsf.RemotePath) {
return fmt.Errorf("unexpected relative path: %q", rsf.RemotePath)
}
Expand Down Expand Up @@ -327,3 +331,14 @@ func (rsf *ReverseSSHFS) Close() error {
}
return nil
}

// convertMSYS2Path converts an MSYS2 style path (e.g., /c/Users/...) to a Windows native path
func convertMSYS2Path(localPath string) string {
if len(localPath) >= 3 && localPath[0] == '/' && localPath[2] == '/' {
driveLetter := strings.ToUpper(string(localPath[1]))
// Explicitly force backslashes, bypassing WSL/Linux environment quirks
remainingPath := strings.ReplaceAll(localPath[2:], "/", "\\")
return driveLetter + ":" + remainingPath
}
return localPath
}
13 changes: 13 additions & 0 deletions pkg/reversesshfs/reversesshfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ func TestAddQuotes(t *testing.T) {
}
}
}

func TestConvertMSYS2Path(t *testing.T) {
inputPath := "/c/Users/lts"
expectedPath := "C:\\Users\\lts"

actualPath := convertMSYS2Path(inputPath)

if actualPath != expectedPath {
t.Errorf("Conversion failed: expected %q, got %q", expectedPath, actualPath)
} else {
t.Logf("Success! Converted path for native Windows OpenSSH: %q", actualPath)
}
}