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

add console users when remote is false instead of looking at seat #1453

Merged
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
29 changes: 18 additions & 11 deletions ee/consoleuser/consoleuser_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,29 @@ func CurrentUids(ctx context.Context) ([]string, error) {
continue
}

// if there is no seat, this is not a graphical session
if s.Seat == "" {
continue
}
output, err := exec.CommandContext(ctx,
"loginctl",
"show-session", s.Session,
"--property=Remote",
"--property=Active",
).Output()

// get the active property of the session, this command does not respect the --output=json flag
output, err := exec.CommandContext(ctx, "loginctl", "show-session", s.Session, "--value", "--property=Active").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
Loading