]> git.ipfire.org Git - thirdparty/util-linux.git/commit
agetty: fix login name DEL/CTRL^U issue
authorKarel Zak <kzak@redhat.com>
Fri, 23 Jun 2017 12:26:47 +0000 (14:26 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 23 Jun 2017 13:07:32 +0000 (15:07 +0200)
commitc32cd3f1a95b9d0ddac1287862319aa13879e3a8
treed5deb6c6549961c9d5bb587c2114e78fda2e2e2b
parentd200c0a678d7f8f030d524da1a489944373bfe49
agetty: fix login name DEL/CTRL^U issue

agetty refresh prompt (/etc/issue file etc.) when requested by inotify
or netlink. For this purpose we monitor some file descriptors by
select().

The terminal input file descriptor is switched to non-canonical mode before
select(). The goal is to be informed about user activity before
new-line. The FD is immediately switched back to canonical mode when
activity is detected. The side effect is that all not-read-yet chars in
the input buffer are lost ... so we need to call read() before switch
to canonical mode to save the chars.

The original implementation has been based on TIOCSTI ioctl. It
returns already read chars back to the terminal input buffer to make
them useful for canonical mode. The problem was race (agetty writes to
input buffer in the same time as user) and result was reordered chars
in login name... so useless.

This issue has been later fixed by extra buffer (commit
790119b8850ae13bb4254c5096a54b2aeb355b20) for already read data.  And
TIOCSTI ioctl has been removed. Unfortunately this solution is also
wrong, because the buffer is maintained only by agetty and
inaccessible for terminal when user edit (by DEL/CTRL^U) login name in
canonical mode.

The solution is simple -- just don't try to be smart and keep terminal
in canonical mode all time (so terminal controls DEL, CTRL^U, etc) and
flush input buffer (=discard unread data) and ask user for login name
again after prompt reload.

The agetty reload is very rarely situation and for user it's pretty
obvious that he has to type login name again (as all terminal has been
clear+redraw).

Addresses: https://github.com/karelzak/util-linux/issues/454
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1464148
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c