diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-25 23:23:58 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-25 23:23:58 +0000 |
commit | 6f1713f216fef686a68db5ee02232bc67e525c7d (patch) | |
tree | 256adc75a88723a4b247c32e692d721d65243a82 /libbb/login.c | |
parent | 394eebed6656dfc2e56a79500b602023000ac415 (diff) | |
download | busybox-w32-6f1713f216fef686a68db5ee02232bc67e525c7d.tar.gz busybox-w32-6f1713f216fef686a68db5ee02232bc67e525c7d.tar.bz2 busybox-w32-6f1713f216fef686a68db5ee02232bc67e525c7d.zip |
*: intrduce and use safe_gethostname. By Tito <farmatito AT tiscali.it>
safe_gethostname - 48 +48
glob3 35 37 +2
timestamp_and_log 314 315 +1
udhcp_send_kernel_packet 234 231 -3
scan_tree 275 271 -4
passwd_main 1074 1070 -4
print_login_prompt 68 58 -10
obscure 392 377 -15
syslogd_main 882 866 -16
print_login_issue 516 478 -38
hostname_main 278 223 -55
parse_and_put_prompt 825 756 -69
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/9 up/down: 51/-214) Total: -163 bytes
text data bss dec hex filename
798791 728 7484 807003 c505b busybox_old
798631 728 7484 806843 c4fbb busybox_unstripped
Diffstat (limited to 'libbb/login.c')
-rw-r--r-- | libbb/login.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/libbb/login.c b/libbb/login.c index d1f5d6498..a711a5437 100644 --- a/libbb/login.c +++ b/libbb/login.c | |||
@@ -50,6 +50,7 @@ void print_login_issue(const char *issue_file, const char *tty) | |||
50 | outbuf = uts.sysname; | 50 | outbuf = uts.sysname; |
51 | break; | 51 | break; |
52 | case 'n': | 52 | case 'n': |
53 | case 'h': | ||
53 | outbuf = uts.nodename; | 54 | outbuf = uts.nodename; |
54 | break; | 55 | break; |
55 | case 'r': | 56 | case 'r': |
@@ -72,10 +73,6 @@ void print_login_issue(const char *issue_file, const char *tty) | |||
72 | case 't': | 73 | case 't': |
73 | strftime(buf, sizeof(buf), fmtstr_t, localtime(&t)); | 74 | strftime(buf, sizeof(buf), fmtstr_t, localtime(&t)); |
74 | break; | 75 | break; |
75 | case 'h': | ||
76 | gethostname(buf, sizeof(buf) - 1); | ||
77 | buf[sizeof(buf) - 1] = '\0'; | ||
78 | break; | ||
79 | case 'l': | 76 | case 'l': |
80 | outbuf = tty; | 77 | outbuf = tty; |
81 | break; | 78 | break; |
@@ -91,13 +88,12 @@ void print_login_issue(const char *issue_file, const char *tty) | |||
91 | 88 | ||
92 | void print_login_prompt(void) | 89 | void print_login_prompt(void) |
93 | { | 90 | { |
94 | char buf[MAXHOSTNAMELEN+1]; | 91 | char *hostname = safe_gethostname(); |
95 | 92 | ||
96 | if (gethostname(buf, MAXHOSTNAMELEN) == 0) | 93 | fputs(hostname, stdout); |
97 | fputs(buf, stdout); | ||
98 | |||
99 | fputs(LOGIN, stdout); | 94 | fputs(LOGIN, stdout); |
100 | fflush(stdout); | 95 | fflush(stdout); |
96 | free(hostname); | ||
101 | } | 97 | } |
102 | 98 | ||
103 | /* Clear dangerous stuff, set PATH */ | 99 | /* Clear dangerous stuff, set PATH */ |