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/su-common.c | |
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/su-common.c')
-rw-r--r-- | login-utils/su-common.c | 4 |
1 files changed, 2 insertions, 2 deletions
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) |