Skip to content

Commit

Permalink
Try looking for Xvfb process too
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Nov 22, 2023
1 parent fdea31f commit 9748457
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
12 changes: 7 additions & 5 deletions ee/desktop/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,13 @@ func (r *DesktopUsersProcessesRunner) writeDefaultMenuTemplateFile() {
}

func (r *DesktopUsersProcessesRunner) runConsoleUserDesktop() error {
if !r.processSpawningEnabled {
// Desktop is disabled, kill any existing desktop user processes
r.killDesktopProcesses()
return nil
}
/*
if !r.processSpawningEnabled {
// Desktop is disabled, kill any existing desktop user processes
r.killDesktopProcesses()
return nil
}
*/

executablePath, err := r.determineExecutablePath()
if err != nil {
Expand Down
19 changes: 11 additions & 8 deletions ee/desktop/runner/runner_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,30 +172,30 @@ func (r *DesktopUsersProcessesRunner) displayFromX11(ctx context.Context, sessio
"msg", "could not create command to get Display from user session",
"err", err,
)
return r.displayFromXorgProcess(ctx, uid)
return r.displayFromXDisplayServerProcess(ctx, uid)
}
xDisplayOutput, err := cmd.Output()
if err != nil {
level.Debug(r.logger).Log(
"msg", "could not get Display from user session",
"err", err,
)
return r.displayFromXorgProcess(ctx, uid)
return r.displayFromXDisplayServerProcess(ctx, uid)
}

display := strings.Trim(string(xDisplayOutput), "\n")
if display == "" {
return r.displayFromXorgProcess(ctx, uid)
return r.displayFromXDisplayServerProcess(ctx, uid)
}

return display
}

func (r *DesktopUsersProcessesRunner) displayFromXorgProcess(ctx context.Context, uid int32) string {
func (r *DesktopUsersProcessesRunner) displayFromXDisplayServerProcess(ctx context.Context, uid int32) string {
processes, err := process.ProcessesWithContext(ctx)
if err != nil {
level.Debug(r.logger).Log(
"msg", "could not query processes to find Xorg process",
"msg", "could not query processes to find display server process",
"err", err,
)
return defaultDisplay
Expand All @@ -211,11 +211,11 @@ func (r *DesktopUsersProcessesRunner) displayFromXorgProcess(ctx context.Context
continue
}

if !strings.Contains(cmdline, "Xorg") {
if !strings.Contains(cmdline, "Xorg") && !strings.Contains(cmdline, "Xvfb") {
continue
}

// We have an Xorg process -- check to make sure it's for our running user
// We have an Xorg or Xvfb process -- check to make sure it's for our running user
uids, err := p.UidsWithContext(ctx)
if err != nil {
level.Debug(r.logger).Log(
Expand All @@ -233,8 +233,11 @@ func (r *DesktopUsersProcessesRunner) displayFromXorgProcess(ctx context.Context
}

if uidMatch {
// We have a match! Grab the display value. The Xorg process looks like:
// We have a match! Grab the display value.
// The Xorg process looks 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
cmdlineArgs := strings.Split(cmdline, " ")
if len(cmdlineArgs) < 2 {
// Process is somehow malformed or not what we're looking for -- continue so we can evaluate the following process
Expand Down

0 comments on commit 9748457

Please sign in to comment.