summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2016-03-15 15:45:17 +1300
committerRobert Ancell <robert.ancell@canonical.com>2016-03-15 15:45:17 +1300
commit2f684f54018e5fa36b40282c6f0d98fd08cfcb12 (patch)
tree770de73bdfb176951dab6c77c389ea020e09bb3e
parentd3d1488fd4800175492c08c546f7506139dc480b (diff)
downloadlightdm-2f684f54018e5fa36b40282c6f0d98fd08cfcb12.tar.gz
Don't write :0 into tty line in utmp/btmp. Based on a patch by Harald Judt
-rw-r--r--src/session-child.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/session-child.c b/src/session-child.c
index 36569423..e393ce4c 100644
--- a/src/session-child.c
+++ b/src/session-child.c
@@ -408,11 +408,8 @@ session_child_run (int argc, char **argv)
ut.ut_type = USER_PROCESS;
ut.ut_pid = getpid ();
if (xdisplay)
- {
- strncpy (ut.ut_line, xdisplay, sizeof (ut.ut_line));
strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
- }
- else if (tty)
+ if (tty && g_str_has_prefix (tty, "/dev/"))
strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line));
strncpy (ut.ut_user, username, sizeof (ut.ut_user));
if (xdisplay)
@@ -732,11 +729,8 @@ session_child_run (int argc, char **argv)
ut.ut_type = USER_PROCESS;
ut.ut_pid = child_pid;
if (xdisplay)
- {
- strncpy (ut.ut_line, xdisplay, sizeof (ut.ut_line));
strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
- }
- else if (tty)
+ if (tty && g_str_has_prefix (tty, "/dev/"))
strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line));
strncpy (ut.ut_user, username, sizeof (ut.ut_user));
if (xdisplay)
@@ -772,11 +766,8 @@ session_child_run (int argc, char **argv)
ut.ut_type = DEAD_PROCESS;
ut.ut_pid = child_pid;
if (xdisplay)
- {
- strncpy (ut.ut_line, xdisplay, sizeof (ut.ut_line));
strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
- }
- else if (tty)
+ if (tty && g_str_has_prefix (tty, "/dev/"))
strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line));
strncpy (ut.ut_user, username, sizeof (ut.ut_user));
if (xdisplay)