aboutsummaryrefslogtreecommitdiff
path: root/sysklogd/syslogd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysklogd/syslogd.c')
-rw-r--r--sysklogd/syslogd.c25
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 */
55static int remoteFD = -1; 55static int remoteFD = -1;
56static struct sockaddr_in remoteAddr; 56static 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;
464static void do_syslogd(void) 464static 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