lightdm writes XDISPLAY instead of tty device name to utmp record

Bug #1380364 reported by Harald Judt on 2014-10-12
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Light Display Manager
lightdm (Ubuntu)
unity-control-center (Ubuntu)

Bug Description

Until now, I've been using good old gdm-2.20.11 and wanted to switch to lightdm-1.12.1. If you list users logged in via the 'w' or 'who' command, it shows you who is logged in and what they are doing. Especially, on which tty. Example:

user tty9 03Oct14 16days 1:52m 0.01s /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserverrc

Also, 'who' gives this information:
user tty9 Oct 3 22:34 (:20)

However, lightdm does not follow that tradition. Instead, it prints :0 instead of the actual tty, and something weird for other values (like ?xdm? instead of the idle value etc.)

user :0 19:50 ?xdm? 23.82s 0.01s /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserverrc

Note: :0 is not tty, it is DISPLAY env.

user :0 2014-10-12 19:50 (:0)

The same for this one. I wonder, is this a bug (to me it seems so, because for every other program the correct values are reported)?

It is a problem for me, because I have written scripts for automation etc. that parse w and who output to determine which tty is in use by which DISPLAY.

Related branches

Harald Judt (hjudt) wrote :

This is a bug in lightdm which should be fixed. tty line and idle time are not shown correctly. XDISPLAY should not be written to ut_line.

summary: - lightdm and wrong 'w' and 'who' output
+ lightdm writes XDISPLAY instead of tty device name to utmp record
Harald Judt (hjudt) wrote :

The patch applies to lightdm-1.15.0.

Lectrode (electrodexsnet) wrote :

problem still persists in lightdm 1.16.7

Is there any news on this bug?

Changed in lightdm:
status: New → Fix Committed
importance: Undecided → Medium
Changed in lightdm:
milestone: none → 1.17.6
Changed in lightdm (Ubuntu):
status: New → Fix Committed
importance: Undecided → Medium

The attachment "0001-Fix-tty-not-written-to-utmp-ut_line.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lightdm - 1.17.6-0ubuntu1

lightdm (1.17.6-0ubuntu1) xenial; urgency=medium

  * New upstream release:
    - Don't write $DISPLAY into tty line in utmp/btmp. (LP: #1380364)
  * debian/
  * debian/guest-session.profile:
  * debian/rules:
    - Don't overwrite .profile file from skeleton session, append it instead

 -- Robert Ancell <email address hidden> Tue, 15 Mar 2016 15:47:08 +1300

Changed in lightdm (Ubuntu):
status: Fix Committed → Fix Released
Changed in lightdm:
status: Fix Committed → Fix Released
Sebastien Bacher (seb128) wrote :

That change made the unity-control-center user's panel history dialog stop working since it's filtering graphical session by they ":" entries and now those are writted as "tty"

See for some context

We either need to revert that change or to update u-c-c, note that the issue should be sorted out before an eventual SRU of the lightdm change

Robert Ancell (robert-ancell) wrote :

I'm really struggling to find the correct behaviour here. What I know:
- man utmp shows:
char ut_line[UT_LINESIZE]; /* Device name of tty - "/dev/" */
- GDM 2.20 only put the tty into this field
- GDM git does:
         * Set ut_line to the device name associated with this display
         * but remove the "/dev/" prefix. If no device, then use the
         * $DISPLAY value.
        if (display_device != NULL
            && g_str_has_prefix (display_device, "/dev/")) {
                strncpy (u->ut_line,
                         display_device + strlen ("/dev/"),
                         sizeof (u->ut_line));
        } else if (x11_display_name != NULL) {
                strncpy (u->ut_line,
                         sizeof (u->ut_line));
- 'w' (the version in procps anyway) does:
                if (*u->ut_line == ':')
                        /* idle unknown for xdm logins */
                        printf(" ?xdm? ");
- xdm (1.1.11) doesn't set ut_line at all.
- AccountsService only stores ut_line and ut_tv (the timestamp) as a login record.
- gnome-control-center checks the history via AccountsService and checks if ut_line has the prefix ":" or "tty"

So while this clearly wasn't intended when utmp/wtmp was designed it seems everyone is using ut_line with ttyN for text logins and :n for X logins. That suggests we should revert the patch in LightDM.

I haven't been able to get GDM to work on my machine, can someone confirm the output of w in a modern GDM?

Martin Pitt (pitti) wrote :

I cannot get gdm to work in a VM either; it starts, but I just see a black screen.

I tried under LXDM in Debian sid, but that doesn't seem to register any session at all ("w" is empty except for the table header).

I also tried gdm3 on sid with the default (Cirrus), -vga virtio, and -vga vmware, and in none of these cases it starts. Maybe it needs some configuration after apt-get install gdm. So perhaps someone could try this under Ubuntu GNOME?

Jeremy Bicha (jbicha) wrote :

Ubuntu GNOME 16.10 with GNOME 3.20 (from the xenial GNOME3 Staging PPA)

$ w
 09:47:04 up 1 day, 6:26, 3 users, load average: 0.27, 0.39, 0.49
jeremy tty2 :0 Sun03 30:26m 4:19m 1.33s /usr/lib/telepathy/telepathy-salut
jeremy pts/6 tmux(27978).%1 Sun21 3:20 16.63s 16.57s weechat
jeremy pts/8 tmux(27978).%2 01:39 7:59m 0.18s 0.18s /bin/bash

Robert Ancell (robert-ancell) wrote :

Thanks Martin, Jeremy.

The GDM log suggests the currently LightDM behaviour is the same. In that case we should revert the u-c-c change (and lose the ability to hide non graphical logins). We could filter out non-graphical logins by checking if the tty is less than 7 (yes, it's a total hack) or look at making AccountsService change the value it provides for X cases (probably the better option).

Changed in unity-control-center (Ubuntu):
importance: Undecided → High
status: New → In Progress
Jeremy Bicha (jbicha) wrote :

> We could filter out non-graphical logins by checking if the tty is less than 7

gdm3 in Ubuntu GNOME 16.10 (and backported to 16.04 via the Staging PPA because why not?) starts on vt1 and the first login is vt2, etc. That change was made in Debian's gdm3 packaging.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package unity-control-center - 15.04.0+16.10.20161003.1-0ubuntu1

unity-control-center (15.04.0+16.10.20161003.1-0ubuntu1) yakkety; urgency=medium

  [ Robert Ancell ]
  * Don't check if we're running under Unity - we only support Unity
    (LP: #1554878, #1629668)
  * Ubuntu only supports usernames with lowercase letters. (LP:

  [ Sebastien Bacher ]
  * Revert the change from r12750 to include only graphical sessions.
    (LP: #1380364)

  [ <email address hidden> ]
  * Removed "when battery is critical" functionality from the power
    panel as this is now handled by Upower and these settings now do
    nothing. Fixes LP: #1599264 (LP: #1599264)

 -- <email address hidden> (<email address hidden>) Mon, 03 Oct 2016 11:19:09 +0000

Changed in unity-control-center (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers