summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorDenis Vlasenko2008-12-23 23:36:47 +0000
committerDenis Vlasenko2008-12-23 23:36:47 +0000
commit4e12b1a2a9e68685dff61acaee1e1f6c377d978c (patch)
tree6d2745f77060d05f843eb186c5227246667d33cb /loginutils
parentb3523b9cd3ba71b82e36466b17aae3d65a53203e (diff)
downloadbusybox-4e12b1a2a9e68685dff61acaee1e1f6c377d978c.zip
busybox-4e12b1a2a9e68685dff61acaee1e1f6c377d978c.tar.gz
libbb: introduce and use xmalloc_ttyname (-32 in bss).
ash: small code shrink text data bss dec hex filename 793669 504 7524 801697 c3ba1 busybox_old 793659 504 7492 801655 c3b77 busybox_unstripped
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 a18b4d5..af87143 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 e7e0001..de8c18d 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);
}