From: Karel Zak Date: Thu, 22 Nov 2012 13:42:10 +0000 (+0100) Subject: login: use get_terminal_name() from ttyutils.c X-Git-Tag: v2.23-rc1~503 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70aaa7308ba771ab832023fabe5f782d92b332cc;p=thirdparty%2Futil-linux.git login: use get_terminal_name() from ttyutils.c Signed-off-by: Karel Zak --- 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 */