diff options
author | Karel Zak | 2012-11-22 14:42:10 +0100 |
---|---|---|
committer | Karel Zak | 2012-11-22 14:42:10 +0100 |
commit | 70aaa7308ba771ab832023fabe5f782d92b332cc (patch) | |
tree | 359b2d268e9f95e14c2d917992be8ff21965fcd2 /login-utils | |
parent | lib/ttyutils: add get_terminal_name() (diff) | |
download | kernel-qcow2-util-linux-70aaa7308ba771ab832023fabe5f782d92b332cc.tar.gz kernel-qcow2-util-linux-70aaa7308ba771ab832023fabe5f782d92b332cc.tar.xz kernel-qcow2-util-linux-70aaa7308ba771ab832023fabe5f782d92b332cc.zip |
login: use get_terminal_name() from ttyutils.c
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils')
-rw-r--r-- | login-utils/login.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/login-utils/login.c b/login-utils/login.c index 53df1345a..534da4250 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 */ |