aboutsummaryrefslogtreecommitdiff
path: root/sysklogd
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-25 23:23:58 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-25 23:23:58 +0000
commit6f1713f216fef686a68db5ee02232bc67e525c7d (patch)
tree256adc75a88723a4b247c32e692d721d65243a82 /sysklogd
parent394eebed6656dfc2e56a79500b602023000ac415 (diff)
downloadbusybox-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 'sysklogd')
-rw-r--r--sysklogd/syslogd.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 0dc69d8cc..0d004bc27 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -97,8 +97,8 @@ struct globals {
97 struct shbuf_ds *shbuf; 97 struct shbuf_ds *shbuf;
98#endif 98#endif
99 time_t last_log_time; 99 time_t last_log_time;
100 /* localhost's name */ 100 /* localhost's name. We print only first 64 chars */
101 char localHostName[64]; 101 char *hostname;
102 102
103 /* We recv into recvbuf... */ 103 /* We recv into recvbuf... */
104 char recvbuf[MAX_READ]; 104 char recvbuf[MAX_READ];
@@ -416,7 +416,7 @@ static void timestamp_and_log(int pri, char *msg, int len)
416 else { 416 else {
417 char res[20]; 417 char res[20];
418 parse_fac_prio_20(pri, res); 418 parse_fac_prio_20(pri, res);
419 sprintf(G.printbuf, "%s %s %s %s\n", timestamp, G.localHostName, res, msg); 419 sprintf(G.printbuf, "%s %.64s %s %s\n", timestamp, G.hostname, res, msg);
420 } 420 }
421 421
422 /* Log message locally (to file or shared mem) */ 422 /* Log message locally (to file or shared mem) */
@@ -647,11 +647,8 @@ int syslogd_main(int argc, char **argv)
647 option_mask32 |= OPT_locallog; 647 option_mask32 |= OPT_locallog;
648 648
649 /* Store away localhost's name before the fork */ 649 /* Store away localhost's name before the fork */
650 /* "It is unspecified whether the truncated hostname 650 G.hostname = safe_gethostname();
651 * will be null-terminated". We give it (size - 1), 651 *strchrnul(G.hostname, '.') = '\0';
652 * thus last byte will be NUL no matter what. */
653 gethostname(G.localHostName, sizeof(G.localHostName) - 1);
654 *strchrnul(G.localHostName, '.') = '\0';
655 652
656 if (!(option_mask32 & OPT_nofork)) { 653 if (!(option_mask32 & OPT_nofork)) {
657 bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv); 654 bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);