aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/login.c8
-rw-r--r--loginutils/su.c2
2 files changed, 5 insertions, 5 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index a18b4d5d7..af871436a 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -275,7 +275,7 @@ int login_main(int argc UNUSED_PARAM, char **argv)
if (!isatty(0) || !isatty(1) || !isatty(2))
return EXIT_FAILURE; /* Must be a terminal */
safe_strncpy(full_tty, "UNKNOWN", sizeof(full_tty));
- tmp = ttyname(0);
+ tmp = xmalloc_ttyname(STDIN_FILENO);
if (tmp) {
safe_strncpy(full_tty, tmp, sizeof(full_tty));
if (strncmp(full_tty, "/dev/", 5) == 0)
@@ -285,12 +285,12 @@ int login_main(int argc UNUSED_PARAM, char **argv)
read_or_build_utent(&utent, run_by_root);
if (opt & LOGIN_OPT_h) {
- USE_FEATURE_UTMP(
+ if (ENABLE_FEATURE_UTMP)
safe_strncpy(utent.ut_host, opt_host, sizeof(utent.ut_host));
- )
fromhost = xasprintf(" on '%s' from '%s'", short_tty, opt_host);
- } else
+ } else {
fromhost = xasprintf(" on '%s'", short_tty);
+ }
/* Was breaking "login <username>" from shell command line: */
/*bb_setpgrp();*/
diff --git a/loginutils/su.c b/loginutils/su.c
index e7e0001c7..de8c18d25 100644
--- a/loginutils/su.c
+++ b/loginutils/su.c
@@ -44,7 +44,7 @@ int su_main(int argc UNUSED_PARAM, char **argv)
But getlogin can fail -- usually due to lack of utmp entry.
in this case resort to getpwuid. */
old_user = xstrdup(USE_FEATURE_UTMP(getlogin() ? : ) (pw = getpwuid(cur_uid)) ? pw->pw_name : "");
- tty = ttyname(2) ? : "none";
+ tty = xmalloc_ttyname(2) ? : "none";
openlog(applet_name, 0, LOG_AUTH);
}