diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2016-03-15 16:07:59 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2016-03-15 16:07:59 +1300 |
commit | cd125c4628ede9ed28eaac74b4a8c3c95f0fea9f (patch) | |
tree | 54ede68cbb57b74d3c4a3d561f3cc92d07185f0e | |
parent | d3d1488fd4800175492c08c546f7506139dc480b (diff) | |
download | lightdm-git-cd125c4628ede9ed28eaac74b4a8c3c95f0fea9f.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.c | 15 | ||||
-rw-r--r-- | tests/scripts/utmp-autologin.conf | 8 | ||||
-rw-r--r-- | tests/scripts/utmp-login.conf | 8 | ||||
-rw-r--r-- | tests/scripts/utmp-wrong-password.conf | 2 |
4 files changed, 12 insertions, 21 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) diff --git a/tests/scripts/utmp-autologin.conf b/tests/scripts/utmp-autologin.conf index 5b243d95..1af3e10c 100644 --- a/tests/scripts/utmp-autologin.conf +++ b/tests/scripts/utmp-autologin.conf @@ -21,8 +21,8 @@ user-session=default #?XSERVER-0 ACCEPT-CONNECT # UTMP/WTMP record written -#?UTMP TYPE=USER_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0 -#?WTMP FILE=.*/wtmp TYPE=USER_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0 +#?UTMP TYPE=USER_PROCESS LINE=tty7 ID=:0 USER=have-password1 HOST=:0 +#?WTMP FILE=.*/wtmp TYPE=USER_PROCESS LINE=tty7 ID=:0 USER=have-password1 HOST=:0 # Autologin session starts #?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 @@ -34,8 +34,8 @@ user-session=default #?*SESSION-X-0 LOGOUT # UTMP/WTMP record written -#?UTMP TYPE=DEAD_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0 -#?WTMP FILE=.*/wtmp TYPE=DEAD_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0 +#?UTMP TYPE=DEAD_PROCESS LINE=tty7 ID=:0 USER=have-password1 HOST=:0 +#?WTMP FILE=.*/wtmp TYPE=DEAD_PROCESS LINE=tty7 ID=:0 USER=have-password1 HOST=:0 # X server stops #?XSERVER-0 TERMINATE SIGNAL=15 diff --git a/tests/scripts/utmp-login.conf b/tests/scripts/utmp-login.conf index 213afb15..594f9737 100644 --- a/tests/scripts/utmp-login.conf +++ b/tests/scripts/utmp-login.conf @@ -36,8 +36,8 @@ user-session=default #?GREETER-X-0 TERMINATE SIGNAL=15 # UTMP/WTMP record written -#?UTMP TYPE=USER_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0 -#?WTMP FILE=.*/wtmp TYPE=USER_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0 +#?UTMP TYPE=USER_PROCESS LINE=tty7 ID=:0 USER=have-password1 HOST=:0 +#?WTMP FILE=.*/wtmp TYPE=USER_PROCESS LINE=tty7 ID=:0 USER=have-password1 HOST=:0 # Session starts #?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 @@ -49,8 +49,8 @@ user-session=default #?*SESSION-X-0 LOGOUT # UTMP/WTMP record written -#?UTMP TYPE=DEAD_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0 -#?WTMP FILE=.*/wtmp TYPE=DEAD_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0 +#?UTMP TYPE=DEAD_PROCESS LINE=tty7 ID=:0 USER=have-password1 HOST=:0 +#?WTMP FILE=.*/wtmp TYPE=DEAD_PROCESS LINE=tty7 ID=:0 USER=have-password1 HOST=:0 # X server stops #?XSERVER-0 TERMINATE SIGNAL=15 diff --git a/tests/scripts/utmp-wrong-password.conf b/tests/scripts/utmp-wrong-password.conf index b9090752..ef10b414 100644 --- a/tests/scripts/utmp-wrong-password.conf +++ b/tests/scripts/utmp-wrong-password.conf @@ -28,7 +28,7 @@ check-events=true #?*GREETER-X-0 AUTHENTICATE USERNAME=have-password1 #?GREETER-X-0 SHOW-PROMPT TEXT="Password:" #?*GREETER-X-0 RESPOND TEXT="rubbish" -#?WTMP FILE=.*/btmp TYPE=USER_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0 +#?WTMP FILE=.*/btmp TYPE=USER_PROCESS LINE=tty7 ID=:0 USER=have-password1 HOST=:0 #?GREETER-X-0 AUTHENTICATION-COMPLETE USERNAME=have-password1 AUTHENTICATED=FALSE # Cleanup |