diff options
author | Sami Kerola | 2016-05-14 20:50:41 +0200 |
---|---|---|
committer | Sami Kerola | 2016-07-04 00:35:10 +0200 |
commit | 285c1f3a3eda762897d45f698e94c461d68e8d68 (patch) | |
tree | e2b99cdb523a2f4341e68da397310925df91f402 /login-utils | |
parent | write: stop removing and adding /dev/ in front of tty string (diff) | |
download | kernel-qcow2-util-linux-285c1f3a3eda762897d45f698e94c461d68e8d68.tar.gz kernel-qcow2-util-linux-285c1f3a3eda762897d45f698e94c461d68e8d68.tar.xz kernel-qcow2-util-linux-285c1f3a3eda762897d45f698e94c461d68e8d68.zip |
lib: try to find tty in get_terminal_name()
Try all standard terminal input/output file descriptors when finding tty
name in get_germinal_name(). This should make all invocations of the
function as robust as they can get.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils')
-rw-r--r-- | login-utils/login.c | 2 | ||||
-rw-r--r-- | login-utils/su-common.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/login-utils/login.c b/login-utils/login.c index 4d71f5424..7501f6d69 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -356,7 +356,7 @@ static void init_tty(struct login_context *cxt) cxt->tty_mode = (mode_t) getlogindefs_num("TTYPERM", TTY_MODE); - get_terminal_name(0, &cxt->tty_path, &cxt->tty_name, &cxt->tty_number); + 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 diff --git a/login-utils/su-common.c b/login-utils/su-common.c index 78a734c67..1776b6b79 100644 --- a/login-utils/su-common.c +++ b/login-utils/su-common.c @@ -165,7 +165,7 @@ log_syslog(struct passwd const *pw, bool successful) old_user = pwd ? pwd->pw_name : ""; } - if (get_terminal_name(STDERR_FILENO, NULL, &tty, NULL) != 0 || !tty) + if (get_terminal_name(NULL, &tty, NULL) != 0 || !tty) tty = "none"; openlog (program_invocation_short_name, 0 , LOG_AUTH); @@ -192,7 +192,7 @@ static void log_btmp(struct passwd const *pw) pw && pw->pw_name ? pw->pw_name : "(unknown)", sizeof(ut.ut_user)); - get_terminal_name(STDERR_FILENO, NULL, &tty_name, &tty_num); + get_terminal_name(NULL, &tty_name, &tty_num); if (tty_num) xstrncpy(ut.ut_id, tty_num, sizeof(ut.ut_id)); if (tty_name) |