[syslog-ng] [patch] Fixes for 2.0.7 on not ipv6 aware systems
Corinna Vinschen
vinschen at redhat.com
Mon Jan 7 21:32:41 CET 2008
Hi,
I'm maintaining syslog-ng as part of the Cygwin net distro. Today I
tried to build 2.0.7 and came across a couple of problems, which were
mostly due to the fact that the current Cygwin release 1.5.25 is not
ipv6 aware. While this is rectified in Cygwin's CVS, the current
release is still based on older code.
Below you find a patch which solves the following problems:
- Two functions in src/afsocket.c use AF_INET6 even if ENABLED_IPV6
is not defined.
- The new loggen tool has a typo in usage(), printing -i instead of
-I for the interval arg.
- loggen has a bug in the option handling. Due to a missing colon
in the option string, it crashes when using the -s option.
- loggen uses getaddrinfo/freeaddrinfo even on systems on which
HAVE_GETADDRINFO is undefined. I created replacement code using
gethostbyname/gertservbyname on systems lacking getaddrinfo.
ChangeLog and diff below.
Another problem I have is this: Given that loggen is in the tests
subdir, I'm wondering if it's correct that loggen is installed to
${bindir} when running `make install'. Is that really supposed to
happen or should `make install' skip loggen?
Thanks,
Corinna
* src/afsocket.c (afsocket_sd_process_connection): Allow building
with tcp_wrappers if AF_INET6 is unknown.
(afsocket_dd_format_stats_name): Guard AF_INET6 case with ENABLE_IPV6.
* tests/loggen/loggen.c
diff -rup syslog-ng-2.0.7/src/afsocket.c syslog-ng-2.0.7-1/src/afsocket.c
--- syslog-ng-2.0.7/src/afsocket.c 2007-11-26 09:26:38.000000000 +0100
+++ syslog-ng-2.0.7-1/src/afsocket.c 2008-01-07 18:38:31.088449800 +0100
@@ -359,7 +359,11 @@ gboolean
afsocket_sd_process_connection(AFSocketSourceDriver *self, GSockAddr *peer_addr, gint fd)
{
#if ENABLE_TCP_WRAPPER
- if (peer_addr && (peer_addr->sa.sa_family == AF_INET || peer_addr->sa.sa_family == AF_INET6))
+ if (peer_addr && (peer_addr->sa.sa_family == AF_INET
+#if ENABLE_IPV6
+ || peer_addr->sa.sa_family == AF_INET6
+#endif
+ ))
{
struct request_info req;
@@ -693,9 +697,11 @@ afsocket_dd_format_stats_name(AFSocketDe
case AF_INET:
driver_name = !!(self->flags & AFSOCKET_STREAM) ? "tcp" : "udp";
break;
+#if ENABLE_IPV6
case AF_INET6:
driver_name = !!(self->flags & AFSOCKET_STREAM) ? "tcp6" : "udp6";
break;
+#endif
}
g_snprintf(stats_name, sizeof(stats_name), "%s(%s)",
diff -rup syslog-ng-2.0.7/tests/loggen/loggen.c syslog-ng-2.0.7-1/tests/loggen/loggen.c
--- syslog-ng-2.0.7/tests/loggen/loggen.c 2008-01-03 07:29:56.000000000 +0100
+++ syslog-ng-2.0.7-1/tests/loggen/loggen.c 2008-01-07 19:42:46.720451400 +0100
@@ -147,7 +147,7 @@ usage()
" --stream, or -S Use stream socket (TCP and unix-stream)\n"
" --dgram, or -D Use datagram socket (UDP and unix-dgram)\n"
" --size, or -s Specify the size of the syslog message\n"
- " --interval, or -i <sec> Number of seconds to run the test for\n");
+ " --interval, or -I <sec> Number of seconds to run the test for\n");
exit(0);
}
@@ -176,9 +176,9 @@ main(int argc, char *argv[])
int opt;
#if HAVE_GETOPT_LONG
- while ((opt = getopt_long(argc, argv, "r:I:ixsSDh", syslog_ng_options, NULL)) != -1)
+ while ((opt = getopt_long(argc, argv, "r:I:ixs:SDh", syslog_ng_options, NULL)) != -1)
#else
- while ((opt = getopt(argc, argv, "r:I:ixsSDh")) != -1)
+ while ((opt = getopt(argc, argv, "r:I:ixs:SDh")) != -1)
#endif
{
switch (opt)
@@ -211,6 +211,7 @@ main(int argc, char *argv[])
}
if (!unix_socket)
{
+#if HAVE_GETADDRINFO
struct addrinfo hints;
struct addrinfo *res, *rp;
@@ -250,6 +251,53 @@ main(int argc, char *argv[])
fprintf(stderr, "Error connecting to target server: %s\n", strerror(errno));
return 2;
}
+#else
+ struct hostent *host;
+ struct servent *serv = NULL;
+ struct sockaddr_in saddr;
+
+ if (argc - optind < 2)
+ {
+ fprintf(stderr, "No target server specified\n");
+ usage();
+ }
+
+ host = gethostbyname (argv[optind]);
+ if (!host)
+ {
+ fprintf(stderr, "Name lookup error");
+ return 2;
+ }
+ memcpy (&saddr.sin_addr, host->h_addr_list[0], host->h_length);
+ serv = getservbyname (argv[optind + 1],
+ sock_type == SOCK_STREAM ? "tcp" : "udp");
+ if (!serv)
+ {
+ char *c;
+
+ saddr.sin_port = htons (strtol (argv[optind + 1], &c, 10));
+ if (c == argv[optind + 1])
+ {
+ fprintf(stderr, "Service lookup error");
+ return 2;
+ }
+ }
+ else
+ saddr.sin_port = serv->s_port;
+ saddr.sin_family = AF_INET;
+ sock = socket (AF_INET, sock_type, 0);
+ if (sock != -1
+ && connect(sock, (struct sockaddr *) &saddr, sizeof saddr) == -1)
+ {
+ close (sock);
+ sock = -1;
+ }
+ if (sock == -1)
+ {
+ fprintf(stderr, "Error connecting to target server: %s\n", strerror(errno));
+ return 2;
+ }
+#endif
}
else
{
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
More information about the syslog-ng
mailing list