summaryrefslogtreecommitdiffstats
path: root/login-utils/su-common.c
diff options
context:
space:
mode:
authorKarel Zak2012-11-22 14:45:49 +0100
committerKarel Zak2012-11-22 14:45:49 +0100
commitbbc5a5eac417a343b00c713018256d2f31befccb (patch)
tree0eb8442d0585ae47bb3ba1a02c80f6c7c61a18f2 /login-utils/su-common.c
parentlogin: use get_terminal_name() from ttyutils.c (diff)
downloadkernel-qcow2-util-linux-bbc5a5eac417a343b00c713018256d2f31befccb.tar.gz
kernel-qcow2-util-linux-bbc5a5eac417a343b00c713018256d2f31befccb.tar.xz
kernel-qcow2-util-linux-bbc5a5eac417a343b00c713018256d2f31befccb.zip
su: use get_terminal_name() for compatibility with login(1)
login(1) uses tty name (!= path) in the syslog messages. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/su-common.c')
-rw-r--r--login-utils/su-common.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index cd8338088..c5e288d15 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -64,6 +64,7 @@ enum
#include "pathnames.h"
#include "env.h"
#include "closestream.h"
+#include "ttyutils.h"
/* name of the pam configuration files. separate configs for su and su - */
#define PAM_SRVNAME_SU "su"
@@ -154,8 +155,8 @@ log_syslog(struct passwd const *pw, bool successful)
struct passwd *pwd = current_getpwuid();
old_user = pwd ? pwd->pw_name : "";
}
- tty = ttyname (STDERR_FILENO);
- if (!tty)
+
+ if (get_terminal_name(NULL, &tty, NULL) == 0 && tty)
tty = "none";
openlog (program_invocation_short_name, 0 , LOG_AUTH);