From 70aaa7308ba771ab832023fabe5f782d92b332cc Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 22 Nov 2012 14:42:10 +0100 Subject: [PATCH] login: use get_terminal_name() from ttyutils.c Signed-off-by: Karel Zak --- login-utils/login.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/login-utils/login.c b/login-utils/login.c index 53df1345ae..534da42507 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -70,6 +70,7 @@ #include "xalloc.h" #include "all-io.h" #include "fileutils.h" +#include "ttyutils.h" #include "logindefs.h" @@ -350,13 +351,12 @@ static void chown_tty(struct login_context *cxt) */ static void init_tty(struct login_context *cxt) { - const char *p; struct stat st; struct termios tt, ttt; cxt->tty_mode = (mode_t) getlogindefs_num("TTYPERM", TTY_MODE); - cxt->tty_path = ttyname(0); /* libc calls istty() here */ + get_terminal_name(&cxt->tty_path, &cxt->tty_name, &cxt->tty_number); /* * In case login is suid it was possible to use a hardlink as stdin @@ -375,18 +375,6 @@ static void init_tty(struct login_context *cxt) sleepexit(EXIT_FAILURE); } - if (strncmp(cxt->tty_path, "/dev/", 5) == 0) - cxt->tty_name = cxt->tty_path + 5; - else - cxt->tty_name = cxt->tty_path; - - for (p = cxt->tty_name; p && *p; p++) { - if (isdigit(*p)) { - cxt->tty_number = p; - break; - } - } - #ifdef LOGIN_CHOWN_VCS if (cxt->tty_number) { /* find names of Virtual Console devices, for later mode change */ -- 2.47.2