Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into becca/binary-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Nov 14, 2023
2 parents bef1078 + 19cb2b4 commit 99b5e2a
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions ee/consoleuser/consoleuser_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,32 @@ func CurrentUids(ctx context.Context) ([]string, error) {
continue
}

// if there is no seat, this is not a graphical session
if s.Seat == "" {
continue
}

// get the active property of the session, this command does not respect the --output=json flag
cmd, err := allowedcmd.Loginctl(ctx, "show-session", s.Session, "--value", "--property=Active")
cmd, err := allowedcmd.Loginctl(ctx,
"show-session", s.Session,
"--property=Remote",
"--property=Active",
)
if err != nil {
return nil, fmt.Errorf("creating loginctl command: %w", err)
}

output, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("loginctl show-session (for uid %d): %w", s.UID, err)
return nil, fmt.Errorf("loginctl show-session (for sessionId %s): %w", s.Session, err)
}

if strings.Trim(string(output), "\n") != "yes" {
continue
}
// to make remote session behave like local session and include systray icons on ubuntu 22.04
// had to create a ~/.xsessionrc file with the following content:
// export GNOME_SHELL_SESSION_MODE=ubuntu
// export XDG_CURRENT_DESKTOP=ubuntu:GNOME
// export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg

uids = append(uids, fmt.Sprintf("%d", s.UID))
// ssh: remote=yes
// local: remote=no
// rdp: remote=no
if strings.Contains(string(output), "Remote=no") && strings.Contains(string(output), "Active=yes") {
uids = append(uids, fmt.Sprintf("%d", s.UID))
}
}

return uids, nil
Expand Down

0 comments on commit 99b5e2a

Please sign in to comment.