diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2014-03-10 17:20:54 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2014-03-10 17:20:54 +1300 |
commit | 2ff4d7cb8b08315ef9f88c18ccfafa199ef5ded4 (patch) | |
tree | 008cff5b7f1a9a574ee004ab46eeef800f086b0e /src | |
parent | 314b027dfc46999b9f61b3e7ac992dba2254c8fe (diff) | |
download | lightdm-2ff4d7cb8b08315ef9f88c18ccfafa199ef5ded4.tar.gz |
Set utmp ut_line to the display name (i.e. :0). This matches what programs expect (e.g. 'w'). Add tests to check we are setting it correctly.
Diffstat (limited to 'src')
-rw-r--r-- | src/session-child.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/session-child.c b/src/session-child.c index c1c84e5d..57f371a1 100644 --- a/src/session-child.c +++ b/src/session-child.c @@ -601,10 +601,13 @@ session_child_run (int argc, char **argv) memset (&ut, 0, sizeof (ut)); ut.ut_type = USER_PROCESS; ut.ut_pid = child_pid; - if (tty) - strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line)); if (xdisplay) + { + strncpy (ut.ut_line, xdisplay, sizeof (ut.ut_line)); strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id)); + } + else if (tty) + strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line)); strncpy (ut.ut_user, username, sizeof (ut.ut_user)); if (xdisplay) strncpy (ut.ut_host, xdisplay, sizeof (ut.ut_host)); @@ -632,10 +635,13 @@ session_child_run (int argc, char **argv) memset (&ut, 0, sizeof (ut)); ut.ut_type = DEAD_PROCESS; ut.ut_pid = child_pid; - if (tty) - strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line)); if (xdisplay) + { + strncpy (ut.ut_line, xdisplay, sizeof (ut.ut_line)); strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id)); + } + else if (tty) + strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line)); strncpy (ut.ut_user, username, sizeof (ut.ut_user)); if (xdisplay) strncpy (ut.ut_host, xdisplay, sizeof (ut.ut_host)); |