diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-23 23:36:47 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-23 23:36:47 +0000 |
commit | 4e12b1a2a9e68685dff61acaee1e1f6c377d978c (patch) | |
tree | 6d2745f77060d05f843eb186c5227246667d33cb /loginutils | |
parent | b3523b9cd3ba71b82e36466b17aae3d65a53203e (diff) | |
download | busybox-w32-4e12b1a2a9e68685dff61acaee1e1f6c377d978c.tar.gz busybox-w32-4e12b1a2a9e68685dff61acaee1e1f6c377d978c.tar.bz2 busybox-w32-4e12b1a2a9e68685dff61acaee1e1f6c377d978c.zip |
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.c | 8 | ||||
-rw-r--r-- | loginutils/su.c | 2 |
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) | |||
275 | if (!isatty(0) || !isatty(1) || !isatty(2)) | 275 | if (!isatty(0) || !isatty(1) || !isatty(2)) |
276 | return EXIT_FAILURE; /* Must be a terminal */ | 276 | return EXIT_FAILURE; /* Must be a terminal */ |
277 | safe_strncpy(full_tty, "UNKNOWN", sizeof(full_tty)); | 277 | safe_strncpy(full_tty, "UNKNOWN", sizeof(full_tty)); |
278 | tmp = ttyname(0); | 278 | tmp = xmalloc_ttyname(STDIN_FILENO); |
279 | if (tmp) { | 279 | if (tmp) { |
280 | safe_strncpy(full_tty, tmp, sizeof(full_tty)); | 280 | safe_strncpy(full_tty, tmp, sizeof(full_tty)); |
281 | if (strncmp(full_tty, "/dev/", 5) == 0) | 281 | if (strncmp(full_tty, "/dev/", 5) == 0) |
@@ -285,12 +285,12 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
285 | read_or_build_utent(&utent, run_by_root); | 285 | read_or_build_utent(&utent, run_by_root); |
286 | 286 | ||
287 | if (opt & LOGIN_OPT_h) { | 287 | if (opt & LOGIN_OPT_h) { |
288 | USE_FEATURE_UTMP( | 288 | if (ENABLE_FEATURE_UTMP) |
289 | safe_strncpy(utent.ut_host, opt_host, sizeof(utent.ut_host)); | 289 | safe_strncpy(utent.ut_host, opt_host, sizeof(utent.ut_host)); |
290 | ) | ||
291 | fromhost = xasprintf(" on '%s' from '%s'", short_tty, opt_host); | 290 | fromhost = xasprintf(" on '%s' from '%s'", short_tty, opt_host); |
292 | } else | 291 | } else { |
293 | fromhost = xasprintf(" on '%s'", short_tty); | 292 | fromhost = xasprintf(" on '%s'", short_tty); |
293 | } | ||
294 | 294 | ||
295 | /* Was breaking "login <username>" from shell command line: */ | 295 | /* Was breaking "login <username>" from shell command line: */ |
296 | /*bb_setpgrp();*/ | 296 | /*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) | |||
44 | But getlogin can fail -- usually due to lack of utmp entry. | 44 | But getlogin can fail -- usually due to lack of utmp entry. |
45 | in this case resort to getpwuid. */ | 45 | in this case resort to getpwuid. */ |
46 | old_user = xstrdup(USE_FEATURE_UTMP(getlogin() ? : ) (pw = getpwuid(cur_uid)) ? pw->pw_name : ""); | 46 | old_user = xstrdup(USE_FEATURE_UTMP(getlogin() ? : ) (pw = getpwuid(cur_uid)) ? pw->pw_name : ""); |
47 | tty = ttyname(2) ? : "none"; | 47 | tty = xmalloc_ttyname(2) ? : "none"; |
48 | openlog(applet_name, 0, LOG_AUTH); | 48 | openlog(applet_name, 0, LOG_AUTH); |
49 | } | 49 | } |
50 | 50 | ||