From 0c7df652e24be85e49aa5931b27ba6d1382557a8 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 29 May 2023 15:11:48 +0200 Subject: [PATCH] sulogin: use get_terminal_default_type() Let's reuse the way how agetty initializes $TERM. Signed-off-by: Karel Zak --- login-utils/sulogin.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c index 45a558d3ea..b76698561c 100644 --- a/login-utils/sulogin.c +++ b/login-utils/sulogin.c @@ -270,23 +270,21 @@ static void tcfinal(struct console *con) { struct termios *tio = &con->tio; const int fd = con->fd; + char *term, *ttyname = NULL; - if (con->flags & CON_EIO) - return; - if ((con->flags & CON_SERIAL) == 0) { - xsetenv("TERM", "linux", 0); - return; + if (con->tty) + ttyname = strncmp(con->tty, "/dev/", 5) == 0 ? + con->tty + 5 : con->tty; + + term = get_terminal_default_type(ttyname, con->flags & CON_SERIAL); + if (term) { + xsetenv("TERM", term, 0); + free(term); } - if (con->flags & CON_NOTTY) { - xsetenv("TERM", "dumb", 0); + + if (!(con->flags & CON_SERIAL) || (con->flags & CON_NOTTY)) return; - } -#if defined (__s390__) || defined (__s390x__) - xsetenv("TERM", "dumb", 0); -#else - xsetenv("TERM", "vt102", 0); -#endif tio->c_iflag |= (IXON | IXOFF); tio->c_lflag |= (ICANON | ISIG | ECHO|ECHOE|ECHOK|ECHOKE); tio->c_oflag |= OPOST; -- 2.47.3