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

Don't set invalid DISPLAY #1518

Merged
merged 1 commit into from
Dec 19, 2023
Merged
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
12 changes: 10 additions & 2 deletions ee/desktop/runner/runner_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os/exec"
"os/user"
"path/filepath"
"regexp"
"strconv"
"strings"
"syscall"
Expand All @@ -23,6 +24,9 @@ import (

const defaultDisplay = ":0"

// Display takes the format host:displaynumber.screen
var displayRegex = regexp.MustCompile(`^[a-z]*:\d+.?\d*$`)

func (r *DesktopUsersProcessesRunner) runAsUser(ctx context.Context, uid string, cmd *exec.Cmd) error {
ctx, span := traces.StartSpan(ctx, "uid", uid)
defer span.End()
Expand Down Expand Up @@ -234,7 +238,7 @@ func (r *DesktopUsersProcessesRunner) displayFromXDisplayServerProcess(ctx conte

if uidMatch {
// We have a match! Grab the display value.
// The Xorg process looks like:
// The Xorg process may look like:
// /usr/lib/xorg/Xorg :20 -auth /home/<user>/.Xauthority -nolisten tcp -noreset -logfile /dev/null -verbose 3 -config /tmp/chrome_remote_desktop_j5rldjlk.conf
// The Xvfb process looks like:
// Xvfb :20 -auth /home/<user>/.Xauthority -nolisten tcp -noreset -screen 0 3840x2560x24
Expand All @@ -244,7 +248,11 @@ func (r *DesktopUsersProcessesRunner) displayFromXDisplayServerProcess(ctx conte
continue
}

return cmdlineArgs[1]
// Confirm that this is a legitimate display value. (Newer versions of Xorg omit the display value from
// the list of arguments, so we need to weed those out.)
if displayRegex.MatchString(cmdlineArgs[1]) {
return cmdlineArgs[1]
}
}
}

Expand Down
Loading