From 00a284085360fdebc2151c750664bda17d398235 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 6 Jan 2020 18:58:20 +0100 Subject: [PATCH] Allow Ctrl-U, Ctrl-D again in built-in getty Many users found it very frustrating that it was impossible to use standard commands like Ctrl-U and Ctrl-D at the login: prompt. It was never the intention to hamper users for no reason like that. Also, compensate for cursor-up in "Please press Enter" wait-handler. Curiously, this makes everything very neat looking also when having 'nowait' enabled for the tty. Signed-off-by: Joachim Nilsson --- src/getty.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/getty.c b/src/getty.c index c1cabc40..240a7e45 100644 --- a/src/getty.c +++ b/src/getty.c @@ -224,10 +224,15 @@ int getty(char *tty, speed_t speed, char *term, char *user) dup2(fd, STDIN_FILENO); dup2(fd, STDOUT_FILENO); dup2(fd, STDERR_FILENO); + close(fd); if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0) warn("Failed TIOCSCTTY"); + /* Set up TTY, re-enabling ISIG et al. */ + stty(STDIN_FILENO, speed); + (void)write(STDOUT_FILENO, "\n", 1); + /* The getty process is responsible for the UTMP login record */ utmp_set_login(tty, NULL); if (!user) @@ -235,10 +240,6 @@ int getty(char *tty, speed_t speed, char *term, char *user) else strlcpy(name, user, sizeof(name)); - /* Set up TTY, re-enabling ISIG et al. */ - stty(fd, speed); - close(fd); - if (term && term[0]) setenv("TERM", term, 1);