diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-10 20:19:56 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-10 20:19:56 +0000 |
commit | bbe514683a43e81cab1d5ccc0436b9aaf984294b (patch) | |
tree | 5faad36440333e8f1c46c367167e03be65ce8a93 /sysklogd | |
parent | 9de420c27cbbbd99bedc95782a6937039ff071bb (diff) | |
download | busybox-w32-bbe514683a43e81cab1d5ccc0436b9aaf984294b.tar.gz busybox-w32-bbe514683a43e81cab1d5ccc0436b9aaf984294b.tar.bz2 busybox-w32-bbe514683a43e81cab1d5ccc0436b9aaf984294b.zip |
a bit more IPv6-ization work
syslogd: converted to use it (in -R host:port)
Diffstat (limited to 'sysklogd')
-rw-r--r-- | sysklogd/syslogd.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index aa7d516d6..405282796 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -53,7 +53,7 @@ static smallint isRegular; | |||
53 | #include <netinet/in.h> | 53 | #include <netinet/in.h> |
54 | /* udp socket for logging to remote host */ | 54 | /* udp socket for logging to remote host */ |
55 | static int remoteFD = -1; | 55 | static int remoteFD = -1; |
56 | static struct sockaddr_in remoteAddr; | 56 | static len_and_sockaddr* remoteAddr; |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | /* We are using bb_common_bufsiz1 for buffering: */ | 59 | /* We are using bb_common_bufsiz1 for buffering: */ |
@@ -464,7 +464,7 @@ static void do_syslogd(void) ATTRIBUTE_NORETURN; | |||
464 | static void do_syslogd(void) | 464 | static void do_syslogd(void) |
465 | { | 465 | { |
466 | struct sockaddr_un sunx; | 466 | struct sockaddr_un sunx; |
467 | socklen_t addrLength; | 467 | socklen_t addr_len; |
468 | int sock_fd; | 468 | int sock_fd; |
469 | fd_set fds; | 469 | fd_set fds; |
470 | 470 | ||
@@ -491,8 +491,8 @@ static void do_syslogd(void) | |||
491 | sunx.sun_family = AF_UNIX; | 491 | sunx.sun_family = AF_UNIX; |
492 | strncpy(sunx.sun_path, dev_log_name, sizeof(sunx.sun_path)); | 492 | strncpy(sunx.sun_path, dev_log_name, sizeof(sunx.sun_path)); |
493 | sock_fd = xsocket(AF_UNIX, SOCK_DGRAM, 0); | 493 | sock_fd = xsocket(AF_UNIX, SOCK_DGRAM, 0); |
494 | addrLength = sizeof(sunx.sun_family) + strlen(sunx.sun_path); | 494 | addr_len = sizeof(sunx.sun_family) + strlen(sunx.sun_path); |
495 | xbind(sock_fd, (struct sockaddr *) &sunx, addrLength); | 495 | xbind(sock_fd, (struct sockaddr *) &sunx, addr_len); |
496 | 496 | ||
497 | if (chmod(dev_log_name, 0666) < 0) { | 497 | if (chmod(dev_log_name, 0666) < 0) { |
498 | bb_perror_msg_and_die("cannot set permission on %s", dev_log_name); | 498 | bb_perror_msg_and_die("cannot set permission on %s", dev_log_name); |
@@ -524,15 +524,14 @@ static void do_syslogd(void) | |||
524 | #if ENABLE_FEATURE_REMOTE_LOG | 524 | #if ENABLE_FEATURE_REMOTE_LOG |
525 | /* We are not modifying log messages in any way before send */ | 525 | /* We are not modifying log messages in any way before send */ |
526 | /* Remote site cannot trust _us_ anyway and need to do validation again */ | 526 | /* Remote site cannot trust _us_ anyway and need to do validation again */ |
527 | if (option_mask32 & OPT_remotelog) { | 527 | if (remoteAddr) { |
528 | if (-1 == remoteFD) { | 528 | if (-1 == remoteFD) { |
529 | remoteFD = socket(AF_INET, SOCK_DGRAM, 0); | 529 | remoteFD = socket(remoteAddr->sa.sa_family, SOCK_DGRAM, 0); |
530 | } | 530 | } |
531 | if (-1 != remoteFD) { | 531 | if (-1 != remoteFD) { |
532 | /* send message to remote logger, ignore possible error */ | 532 | /* send message to remote logger, ignore possible error */ |
533 | sendto(remoteFD, RECVBUF, i, MSG_DONTWAIT, | 533 | sendto(remoteFD, RECVBUF, i, MSG_DONTWAIT, |
534 | (struct sockaddr *) &remoteAddr, | 534 | &remoteAddr->sa, remoteAddr->len); |
535 | sizeof(remoteAddr)); | ||
536 | } | 535 | } |
537 | } | 536 | } |
538 | #endif | 537 | #endif |
@@ -565,15 +564,7 @@ int syslogd_main(int argc, char **argv) | |||
565 | #endif | 564 | #endif |
566 | #if ENABLE_FEATURE_REMOTE_LOG | 565 | #if ENABLE_FEATURE_REMOTE_LOG |
567 | if (option_mask32 & OPT_remotelog) { // -R | 566 | if (option_mask32 & OPT_remotelog) { // -R |
568 | int port = 514; | 567 | remoteAddr = host2sockaddr(opt_R, 514); |
569 | p = strchr(opt_R, ':'); | ||
570 | if (p) { | ||
571 | *p++ = '\0'; | ||
572 | port = xatou16(p); | ||
573 | } | ||
574 | /* FIXME: looks ip4-specific. need to do better */ | ||
575 | bb_lookup_host(&remoteAddr, opt_R); | ||
576 | remoteAddr.sin_port = bb_lookup_port(port, "udp", port); | ||
577 | } | 568 | } |
578 | //if (option_mask32 & OPT_locallog) // -L | 569 | //if (option_mask32 & OPT_locallog) // -L |
579 | #endif | 570 | #endif |