*: 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
This commit is contained in:
Denis Vlasenko
2008-02-25 23:23:58 +00:00
parent 394eebed66
commit 6f1713f216
8 changed files with 32 additions and 45 deletions

View File

@@ -97,8 +97,8 @@ struct globals {
struct shbuf_ds *shbuf;
#endif
time_t last_log_time;
/* localhost's name */
char localHostName[64];
/* localhost's name. We print only first 64 chars */
char *hostname;
/* We recv into recvbuf... */
char recvbuf[MAX_READ];
@@ -416,7 +416,7 @@ static void timestamp_and_log(int pri, char *msg, int len)
else {
char res[20];
parse_fac_prio_20(pri, res);
sprintf(G.printbuf, "%s %s %s %s\n", timestamp, G.localHostName, res, msg);
sprintf(G.printbuf, "%s %.64s %s %s\n", timestamp, G.hostname, res, msg);
}
/* Log message locally (to file or shared mem) */
@@ -647,11 +647,8 @@ int syslogd_main(int argc, char **argv)
option_mask32 |= OPT_locallog;
/* Store away localhost's name before the fork */
/* "It is unspecified whether the truncated hostname
* will be null-terminated". We give it (size - 1),
* thus last byte will be NUL no matter what. */
gethostname(G.localHostName, sizeof(G.localHostName) - 1);
*strchrnul(G.localHostName, '.') = '\0';
G.hostname = safe_gethostname();
*strchrnul(G.hostname, '.') = '\0';
if (!(option_mask32 & OPT_nofork)) {
bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);