Skip to content

Commit

Permalink
Initial adhoc support for Windows WSL2 (#14)
Browse files Browse the repository at this point in the history
These changes enable the opening of qubesome profiles in Windows with
WSL2.
  • Loading branch information
pjbgf authored Nov 27, 2024
2 parents 1e9c6c5 + dfe86f5 commit c8a0724
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion internal/profiles/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,20 @@ func createNewDisplay(bin string, profile *types.Profile, display string) error
break
}

x11Dir := "/tmp/.X11-unix"
if os.Getenv("WSL_DISTRO_NAME") != "" {
fmt.Println("\033[33mWARN: Running qubesome in WSL is experimental. Some features may not work as expected.\033[0m")
fp, err := filepath.EvalSymlinks(x11Dir)
if err != nil {
return fmt.Errorf("failed to eval symlink: %w", err)
}
x11Dir = fp
}

//nolint
var paths []string
paths = append(paths, "-v=/etc/localtime:/etc/localtime:ro")
paths = append(paths, "-v=/tmp/.X11-unix:/tmp/.X11-unix:rw")
paths = append(paths, fmt.Sprintf("-v=%s:/tmp/.X11-unix:rw", x11Dir))
paths = append(paths, fmt.Sprintf("-v=%s:/tmp/qube.sock:ro", socket))
paths = append(paths, fmt.Sprintf("-v=%s:/home/xorg-user/.Xserver", server))
paths = append(paths, fmt.Sprintf("-v=%s:/home/xorg-user/.Xauthority", workload))
Expand Down
6 changes: 3 additions & 3 deletions internal/util/xauth/xauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
var cookieFunc = newCookie

func AuthPair(display uint8, parent io.Reader, server, client io.Writer) error {
data := make([]byte, 50)
data := make([]byte, 40)
n, err := parent.Read(data)
if err != nil {
return fmt.Errorf("failed to read from parent auth file: %w", err)
}
if n < 50 {
return fmt.Errorf("auth file must be at least 50 chars long: was %d instead", n)
if n < 40 {
return fmt.Errorf("auth file must be at least 40 chars long: was %d instead", n)
}

_, _ = server.Write(data[0:2])
Expand Down

0 comments on commit c8a0724

Please sign in to comment.