From: Karel Zak Date: Mon, 29 May 2023 13:11:48 +0000 (+0200) Subject: sulogin: use get_terminal_default_type() X-Git-Tag: v2.40-rc1~419^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c7df652e24be85e49aa5931b27ba6d1382557a8;p=thirdparty%2Futil-linux.git sulogin: use get_terminal_default_type() Let's reuse the way how agetty initializes $TERM. Signed-off-by: Karel Zak --- 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;