RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1857969 - After login, the "loginctl show-session" command does not show the associated display information
Summary: After login, the "loginctl show-session" command does not show the associated...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: systemd
Version: 8.2
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: 8.0
Assignee: David Tardon
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks: 2100340 2173632
TreeView+ depends on / blocked
 
Reported: 2020-07-16 19:29 UTC by Carlos Santos
Modified: 2023-10-06 21:08 UTC (History)
9 users (show)

Fixed In Version: systemd-239-61.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2100340 2105959 (view as bug list)
Environment:
Last Closed: 2022-11-08 10:49:17 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github redhat-plumbers systemd-rhel8 pull 296 0 None open logind-session-dbus: allow to set display name via dbus 2022-06-23 07:07:51 UTC
Github systemd systemd pull 23749 0 None Merged logind-session-dbus: allow to set display name via dbus 2022-06-23 06:27:30 UTC
Red Hat Product Errata RHBA-2022:7727 0 None None None 2022-11-08 10:49:44 UTC

Description Carlos Santos 2020-07-16 19:29:26 UTC
Description of problem:

When a user logs in via gdm on RHEL- the /run/systemd/sessions/<n> created via
systemd-logind does not contain the DISPLAY information and loginctl can't
show it.

It is also impossible to use sd_session_get_display() to get the display
information programatically.

Version-Release number of selected component (if applicable):

# rpm -q gdm systemd
gdm-3.28.3-29.el8.x86_64
systemd-239-30.el8_2.x86_64

How reproducible:

Always

Steps to Reproduce:

1. Log in as an ordinary user

2. List the existing sessions

   # loginctl list-sessions
   SESSION   UID USER     SEAT  TTY 
        18     0 root               
        25 22174 casantos seat0 tty2
        c3    42 gdm      seat0 tty1

3. Show the user session information

   # loginctl show-session 25

Actual results:

   Id=25
   User=22174
   Name=casantos
   Timestamp=Thu 2020-07-16 16:16:42 -03
   TimestampMonotonic=21677574113
   VTNr=2
   Seat=seat0
   TTY=tty2
   Remote=no
   Service=gdm-password
   Scope=session-25.scope
   Leader=43159
   Audit=25
   Type=wayland
   Class=user
   Active=yes
   State=active
   IdleHint=no
   IdleSinceHint=0
   IdleSinceHintMonotonic=0
   LockedHint=no

Expected results:

   Should show a line containing "Display=:0"

Additional info:

   # cat /run/systemd/sessions/25
   # This is private data. Do not parse.
   UID=22174
   USER=casantos
   ACTIVE=1
   STATE=active
   REMOTE=0
   TYPE=wayland
   CLASS=user
   SCOPE=session-25.scope
   FIFO=/run/systemd/sessions/25.ref
   SEAT=seat0
   TTY=tty2
   SERVICE=gdm-password
   VTNR=2
   LEADER=43159
   AUDIT=25
   REALTIME=1594927002204542
   MONOTONIC=21677574113
   CONTROLLER=:1.2362
   DEVICES=13:65 13:64 13:67 226:0 13:66 13:69 

Disabling Wayland does not make any difference.

It would be good to find a workaround, since there is a customer case in which
the user needs to find the associated display of running sessions by means of
sd_session_get_display().

Comment 1 Carlos Santos 2020-07-16 19:34:06 UTC
The display information is shown correctly in RHEL 7.8, so the current behavior
should be considered is a regression.

Comment 2 Ray Strode [halfline] 2020-08-11 19:40:02 UTC
This is because, in RHEL 8, the X server (or wayland display server) is started as part of the user session instead of as root before the session starts.  loginctl gets passed it's information at the time the session is created.  There's no way we can know the display at that point.

Fixing this requires adding api to logind to allow the session controller to update the display variable after the session is created.

As far as workarounds goes, i'm not sure...  The user could install an autostart file in /etc/xdg/autostart that does omsething like:

[Desktop Entry]
Name=Record Display To Runtime Dir
Exec=sh -c 'echo $DISPLAY > $XDG_RUNTIME_DIR/display'

and then look at /run/user/1000/display to find the session display.

Of course it's better to run things within the session instead of trying to connect to the session from the outside, anyway.

Moving to systemd. If they ack adding the proposed logind API, then I'll add the bits needed in GDM.

Comment 5 Joe Doss 2022-06-14 23:31:14 UTC
I think a workaround could be using sd_session_get_seat()? pam_systemd seems to set $XDG_SEAT based off of $DISPLAY if it is not set. I am not sure what systemd-logind bases SEAT on however. 

https://www.freedesktop.org/software/systemd/man/pam_systemd.html#%24XDG_SEAT

I am trying to figure out what $DISPLAY users have as well on Fedora 36 using Bash. Here are some things I came up with if the seat number lines up with display.

Find X11 env and look for XDG_SEAT:
# DISPLAY=":$(cat /proc/$(pgrep Xorg)/environ | tr '\0' '\n'| grep ^XDG_SEAT|sed -e "s/^XDG_SEAT=seat//")"
# echo $DISPLAY
:0

Use loginctl:
# DISPLAY=":$(loginctl --no-legend list-sessions|grep seat|awk '{print $4}'|sed -e "s/^seat//")"
# echo $DISPLAY
:0

Both of these examples need a for loop or something for multi-sessions. Anyways, I think sd_session_get_seat() could be a workaround here.

Comment 7 Plumber Bot 2022-07-11 08:01:19 UTC
fix merged to github master branch -> https://github.com/redhat-plumbers/systemd-rhel8/pull/296

Comment 12 errata-xmlrpc 2022-11-08 10:49:17 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (systemd bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7727


Note You need to log in before you can comment on or make changes to this bug.