[patch] Fixes for 2.0.7 on not ipv6 aware systems
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
On Jan 7 21:32, Corinna Vinschen wrote:
ChangeLog and diff below. [...]
Oops, sorry, the ChangeLog was incomplete. * 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 (usage): Fix typo in usage output. (main): Require argument for -s in getopt/getopt_long. Add socket handling for systems lacking getaddrinfo/freeaddrinfo. Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat
Hi, Wow, syslog-ng 2.0.7 was not even announced yed, it was released yesterday, I wanted to do the announcement today. On Mon, 2008-01-07 at 21:32 +0100, Corinna Vinschen wrote:
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.
I have commited these patches as they are trivial changes, thus do not need a CLA.
- loggen uses getaddrinfo/freeaddrinfo even on systems on which HAVE_GETADDRINFO is undefined. I created replacement code using gethostbyname/gertservbyname on systems lacking getaddrinfo.
I did not commit this one as this would require a signed CLA. Either I fix this on my own or you sign a Contributory License Agreement. Do you think the latter is feasible for you? http://www.balabit.com/network-security/syslog-ng/opensource-logging-system/...
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?
It was meant to be installed, though putting it to "tests" might not be the best idea. "loggen" can be used to check the performance of one's configuration. -- Bazsi
Hi, On Jan 8 09:13, Balazs Scheidler wrote:
Hi,
Wow, syslog-ng 2.0.7 was not even announced yed, it was released yesterday, I wanted to do the announcement today.
Heh.
On Mon, 2008-01-07 at 21:32 +0100, Corinna Vinschen wrote:
- 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.
I have commited these patches as they are trivial changes, thus do not need a CLA.
Thanks. On second thought, I missed another trivial patch to loggen. The -s option takes a parameter, but the usage string does not reflect that fact: * tests/loggen/loggen.c (usage): Clarify -s usage. --- loggen.c.X 2008-01-08 10:03:03.477272000 +0100 +++ loggen.c 2008-01-08 10:03:11.752376000 +0100 @@ -146,7 +146,7 @@ usage() " --unix, or -x Use UNIX domain socket transport\n" " --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" + " --size, or -s <size> Specify the size of the syslog message\n" " --interval, or -I <sec> Number of seconds to run the test for\n"); exit(0); }
- loggen uses getaddrinfo/freeaddrinfo even on systems on which HAVE_GETADDRINFO is undefined. I created replacement code using gethostbyname/gertservbyname on systems lacking getaddrinfo.
I did not commit this one as this would require a signed CLA. Either I fix this on my own or you sign a Contributory License Agreement. Do you think the latter is feasible for you?
http://www.balabit.com/network-security/syslog-ng/opensource-logging-system/...
Ok with me, but I have to ask my employer first. Given the simplicity of the code, it's probably faster if you just create your own version :)
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?
It was meant to be installed, though putting it to "tests" might not be the best idea. "loggen" can be used to check the performance of one's configuration.
Ok, thanks. I didn't want to create a syslog-ng package for Cygwin with loggen if it's not clear that loggen has to be installed or not. However, "loggen" is easily confused with "logger". Wouldn't something along the lines of "syslog-perf" be a better name for the tool? Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat
On Tue, 2008-01-08 at 10:33 +0100, Corinna Vinschen wrote:
On Mon, 2008-01-07 at 21:32 +0100, Corinna Vinschen wrote:
- 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.
I have commited these patches as they are trivial changes, thus do not need a CLA.
Thanks. On second thought, I missed another trivial patch to loggen. The -s option takes a parameter, but the usage string does not reflect that fact:
* tests/loggen/loggen.c (usage): Clarify -s usage.
--- loggen.c.X 2008-01-08 10:03:03.477272000 +0100 +++ loggen.c 2008-01-08 10:03:11.752376000 +0100 @@ -146,7 +146,7 @@ usage() " --unix, or -x Use UNIX domain socket transport\n" " --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" + " --size, or -s <size> Specify the size of the syslog message\n" " --interval, or -I <sec> Number of seconds to run the test for\n"); exit(0); }
Thanks, I've fixed this together with the getaddrinfo() changes.
- loggen uses getaddrinfo/freeaddrinfo even on systems on which HAVE_GETADDRINFO is undefined. I created replacement code using gethostbyname/gertservbyname on systems lacking getaddrinfo.
I did not commit this one as this would require a signed CLA. Either I fix this on my own or you sign a Contributory License Agreement. Do you think the latter is feasible for you?
http://www.balabit.com/network-security/syslog-ng/opensource-logging-system/...
Ok with me, but I have to ask my employer first. Given the simplicity of the code, it's probably faster if you just create your own version :)
I've just did. The results should be available in our git repository or in the nightly snapshot. Can I ask you to retest whether it compiles fine on cygwin? Thanks for the patches.
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?
It was meant to be installed, though putting it to "tests" might not be the best idea. "loggen" can be used to check the performance of one's configuration.
Ok, thanks. I didn't want to create a syslog-ng package for Cygwin with loggen if it's not clear that loggen has to be installed or not. However, "loggen" is easily confused with "logger". Wouldn't something along the lines of "syslog-perf" be a better name for the tool?
The similarity was intended, I thought it was funny. So if it is not a big problem I would leave it as it is. -- Bazsi
On Jan 8 16:37, Balazs Scheidler wrote:
On Tue, 2008-01-08 at 10:33 +0100, Corinna Vinschen wrote:
* tests/loggen/loggen.c (usage): Clarify -s usage. [...] Thanks, I've fixed this together with the getaddrinfo() changes.
Cool, thank you.
Given the simplicity of the code, it's probably faster if you just create your own version :)
I've just did. The results should be available in our git repository or in the nightly snapshot.
Can I ask you to retest whether it compiles fine on cygwin?
Builds and runs fine on Cygwin. Would the below patch go through as trivial? It just adds the missing getservbyname functionality, which is provided by the getaddrinfo implementation automagically. * tests/loggen/loggen.c (main): Allow symbolic service names for systems not providing getaddrinfo. diff --git a/tests/loggen/loggen.c b/tests/loggen/loggen.c index 608b0ed..f4c6fa4 100644 --- a/tests/loggen/loggen.c +++ b/tests/loggen/loggen.c @@ -250,6 +250,7 @@ main(int argc, char *argv[]) freeaddrinfo(res); #else struct hostent *he; + struct servent *sv; struct sockaddr_in s_in; he = gethostbyname(argv[optind]); @@ -259,7 +260,10 @@ main(int argc, char *argv[]) return 2; } s_in.sin_family = AF_INET; - s_in.sin_port = htons(atoi(argv[optind + 1])); + if ((sv = getservbyname (argv[optind + 1], sock_type == SOCK_STREAM ? "tcp" : "udp"))) + s_in.sin_port = sv->s_port; + else + s_in.sin_port = htons(atoi(argv[optind + 1])); s_in.sin_addr = *(struct in_addr *) he->h_addr; sock = socket(AF_INET, sock_type, 0);
However, "loggen" is easily confused with "logger". Wouldn't something along the lines of "syslog-perf" be a better name for the tool?
The similarity was intended, I thought it was funny. So if it is not a big problem I would leave it as it is.
Sure, no worries. Thanks again, Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat
Ping? On Jan 8 17:17, Corinna Vinschen wrote:
On Jan 8 16:37, Balazs Scheidler wrote:
On Tue, 2008-01-08 at 10:33 +0100, Corinna Vinschen wrote:
* tests/loggen/loggen.c (usage): Clarify -s usage. [...] Thanks, I've fixed this together with the getaddrinfo() changes.
Cool, thank you.
Given the simplicity of the code, it's probably faster if you just create your own version :)
I've just did. The results should be available in our git repository or in the nightly snapshot.
Can I ask you to retest whether it compiles fine on cygwin?
Builds and runs fine on Cygwin. Would the below patch go through as trivial? It just adds the missing getservbyname functionality, which is provided by the getaddrinfo implementation automagically.
* tests/loggen/loggen.c (main): Allow symbolic service names for systems not providing getaddrinfo.
diff --git a/tests/loggen/loggen.c b/tests/loggen/loggen.c index 608b0ed..f4c6fa4 100644 --- a/tests/loggen/loggen.c +++ b/tests/loggen/loggen.c @@ -250,6 +250,7 @@ main(int argc, char *argv[]) freeaddrinfo(res); #else struct hostent *he; + struct servent *sv; struct sockaddr_in s_in;
he = gethostbyname(argv[optind]); @@ -259,7 +260,10 @@ main(int argc, char *argv[]) return 2; } s_in.sin_family = AF_INET; - s_in.sin_port = htons(atoi(argv[optind + 1])); + if ((sv = getservbyname (argv[optind + 1], sock_type == SOCK_STREAM ? "tcp" : "udp"))) + s_in.sin_port = sv->s_port; + else + s_in.sin_port = htons(atoi(argv[optind + 1])); s_in.sin_addr = *(struct in_addr *) he->h_addr;
sock = socket(AF_INET, sock_type, 0);
However, "loggen" is easily confused with "logger". Wouldn't something along the lines of "syslog-perf" be a better name for the tool?
The similarity was intended, I thought it was funny. So if it is not a big problem I would leave it as it is.
Sure, no worries.
Thanks again, Corinna
-- Corinna Vinschen Cygwin Project Co-Leader Red Hat _______________________________________________ syslog-ng maillist - syslog-ng@lists.balabit.hu https://lists.balabit.hu/mailman/listinfo/syslog-ng Frequently asked questions at http://www.campin.net/syslog-ng/faq.html
-- Corinna Vinschen Cygwin Project Co-Leader Red Hat
On Fri, 2008-01-11 at 10:53 +0100, Corinna Vinschen wrote:
On Jan 8 17:17, Corinna Vinschen wrote:
On Jan 8 16:37, Balazs Scheidler wrote:
On Tue, 2008-01-08 at 10:33 +0100, Corinna Vinschen wrote:
* tests/loggen/loggen.c (usage): Clarify -s usage. [...] Thanks, I've fixed this together with the getaddrinfo() changes.
Cool, thank you.
Given the simplicity of the code, it's probably faster if you just create your own version :)
I've just did. The results should be available in our git repository or in the nightly snapshot.
Can I ask you to retest whether it compiles fine on cygwin?
Builds and runs fine on Cygwin. Would the below patch go through as trivial? It just adds the missing getservbyname functionality, which is provided by the getaddrinfo implementation automagically.
* tests/loggen/loggen.c (main): Allow symbolic service names for systems not providing getaddrinfo.
Committed a slightly modified version. Thanks for the patch. -- Bazsi
On Jan 13 08:06, Balazs Scheidler wrote:
On Fri, 2008-01-11 at 10:53 +0100, Corinna Vinschen wrote:
* tests/loggen/loggen.c (main): Allow symbolic service names for systems not providing getaddrinfo.
Committed a slightly modified version. Thanks for the patch.
Thanks! Btw., I have two Cygwin-specific scripts, which are part of the Cygwin syslog-ng package for some time already. I created a contrib/cygwin subdir for them now. Would it be ok to add a contrib/cygwin subdir with these two scripts upstream? I have send the CLA to our legal dept but this might take some time. So I was wondering... do I need the CLA for the stuff under contrib as well? Thanks, Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat
On Mon, 2008-01-14 at 14:51 +0100, Corinna Vinschen wrote:
On Jan 13 08:06, Balazs Scheidler wrote:
On Fri, 2008-01-11 at 10:53 +0100, Corinna Vinschen wrote:
* tests/loggen/loggen.c (main): Allow symbolic service names for systems not providing getaddrinfo.
Committed a slightly modified version. Thanks for the patch.
Thanks!
Btw., I have two Cygwin-specific scripts, which are part of the Cygwin syslog-ng package for some time already. I created a contrib/cygwin subdir for them now.
Would it be ok to add a contrib/cygwin subdir with these two scripts upstream? I have send the CLA to our legal dept but this might take some time. So I was wondering... do I need the CLA for the stuff under contrib as well?
No, contrib is for contributions, they are redistributed with the Premium Edition of syslog-ng, but in source format. So if you submit patches against contrib/, I'm going to include that, and you don't need a CLA. -- Bazsi
On Jan 14 15:18, Balazs Scheidler wrote:
On Mon, 2008-01-14 at 14:51 +0100, Corinna Vinschen wrote:
Would it be ok to add a contrib/cygwin subdir with these two scripts upstream? I have send the CLA to our legal dept but this might take some time. So I was wondering... do I need the CLA for the stuff under contrib as well?
No, contrib is for contributions, they are redistributed with the Premium Edition of syslog-ng, but in source format.
So if you submit patches against contrib/, I'm going to include that, and you don't need a CLA.
Thank you. It's always nice to be able to build upstream without having to tweak anything locally :) Here is a ChangeLog and the diff * contrib/cygwin-packaging/cygwin-postinstall: New script for packing Cygwin net distribution. * contrib/cygwin-packaging/syslog-ng-config: New script for run-time configuration of syslog-ng as part of a Cygwin net distribution. diff --git a/contrib/cygwin-packaging/cygwin-postinstall b/contrib/cygwin-packaging/cygwin-postinstall new file mode 100755 index 0000000..85daf28 --- /dev/null +++ b/contrib/cygwin-packaging/cygwin-postinstall @@ -0,0 +1,57 @@ +#!/bin/sh +DESTDIR="" +if [ -n "$1" ] +then + DESTDIR=$1 +fi +if [ ! -d "contrib/cygwin-packaging" ] +then + echo "Please run 'contrib/cygwin-packaging/cygwin-postinstall' from the top-level source directory." + exit 1 +fi +if [ ! -f "${DESTDIR}/usr/sbin/syslog-ng.exe" ] +then + echo "Please run 'make install-strip' first." + exit 2 +fi +if [ ! -f "config.log" ] +then + echo "Please run './configure' first." + echo "Have a look into 'contrib/cygwin-packaging/cygwin-postinstall' how to do it." + exit 3 +fi +mkdir -p "${DESTDIR}/usr/bin" +mkdir -p "${DESTDIR}/usr/share/doc/syslog-ng" +mkdir -p "${DESTDIR}/usr/share/doc/Cygwin" +cp contrib/cygwin-packaging/syslog-ng-config "${DESTDIR}/usr/bin" +cp -rp doc/examples/syslog-ng.conf.s* doc/reference/syslog-ng.[tx]* "${DESTDIR}/usr/share/doc/syslog-ng" +tar xzfC doc/reference/syslog-ng.html.tar.gz "${DESTDIR}/usr/share/doc/syslog-ng" +cat > "${DESTDIR}/usr/share/doc/Cygwin/syslog-ng.README" <<'EOF' +If you want to use syslog-ng, just run the /usr/bin/syslog-ng-config +script. This script will create a default configuration file +/etc/syslog-ng.conf and it will install syslog-ng as a service on NT +systems on request. + +Please note that you cannot use syslogd from the inetutils package +and syslog-ng together. Only one syslog daemon should run at a time. +The syslog-ng-config script, as well as the latest version of the +syslogd-config script are taking care of this when requested to install +as service. + +The syslog-ng package has been built using the following command +sequence from the top level source dir: + +./configure \ + --disable-ipv6 \ + --disable-tcp-wrapper \ + --prefix=/usr \ + --sysconfdir=/etc \ + --libexecdir='$(prefix)/sbin' \ + --localstatedir=/var \ + --datadir='$(prefix)/share' \ + --mandir='$(prefix)/share/man' \ + --infodir='$(prefix)/share/info' +make +make install-strip +contrib/cygwin-packaging/cygwin-postinstall +EOF diff --git a/contrib/cygwin-packaging/syslog-ng-config b/contrib/cygwin-packaging/syslog-ng-config new file mode 100755 index 0000000..24738c5 --- /dev/null +++ b/contrib/cygwin-packaging/syslog-ng-config @@ -0,0 +1,284 @@ +#!/bin/sh +# +# syslog-ng-config, Copyright 2005, 2006 Corinna Vinschen +# +# This file is part of the Cygwin port of syslog-ng. + +# set -x + +# Subdirectory where the new package is being installed +PREFIX=/usr + +# Directory where the config files are stored +SYSCONFDIR=/etc +DEVDIR=/dev +LOGDIR=/var/log +RUNDIR=/var/run + +progname=$0 +auto_answer="" + +request() +{ + if [ "${auto_answer}" = "yes" ] + then + return 0 + elif [ "${auto_answer}" = "no" ] + then + return 1 + fi + + answer="" + while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ] + do + echo -n "$1 (yes/no) " + read answer + done + if [ "X${answer}" = "Xyes" ] + then + return 0 + else + return 1 + fi +} + +# Check options + +while : +do + case $# in + 0) + break + ;; + esac + + option=$1 + shift + + case "$option" in + -d | --debug ) + set -x + ;; + + -y | --yes ) + auto_answer=yes + ;; + + -n | --no ) + auto_answer=no + ;; + *) + echo "usage: ${progname} [OPTION]..." + echo + echo "This script creates a basic syslog-ng configuration." + echo + echo "Options:" + echo " --debug -d Enable shell's debug output." + echo " --yes -y Answer all questions with \"yes\" automatically." + echo " --no -n Answer all questions with \"no\" automatically." + echo + exit 1 + ;; + + esac +done + +# Check for ${SYSCONFDIR} directory + +if [ -e "${SYSCONFDIR}" -a ! -d "${SYSCONFDIR}" ] +then + echo + echo "${SYSCONFDIR} is existant but not a directory." + echo "Cannot create global configuration files." + echo + exit 1 +fi + +# Create it if necessary + +if [ ! -e "${SYSCONFDIR}" ] +then + mkdir "${SYSCONFDIR}" + if [ ! -e "${SYSCONFDIR}" ] + then + echo + echo "Creating ${SYSCONFDIR} directory failed." + echo + exit 1 + fi +fi +setfacl -m u:system:rwx "${SYSCONFDIR}" + +# Check for ${DEVDIR} directory + +if [ -e "${DEVDIR}" -a ! -d "${DEVDIR}" ] +then + echo + echo "${DEVDIR} is existant but not a directory." + echo "syslogging using syslog-ng will not work." + echo + exit 1 +fi + +# Create it if necessary + +if [ ! -e "${DEVDIR}" ] +then + mkdir "${DEVDIR}" + if [ ! -e "${DEVDIR}" ] + then + echo + echo "Creating ${DEVDIR} directory failed." + echo + exit 1 + fi +fi +setfacl -m u:system:rwx "${DEVDIR}" + +# Check for ${LOGDIR} directory + +if [ -e "${LOGDIR}" -a ! -d "${LOGDIR}" ] +then + echo + echo "${LOGDIR} is existant but not a directory." + echo "syslogging using syslog-ng will not work." + echo + exit 1 +fi + +# Create it if necessary + +if [ ! -e "${LOGDIR}" ] +then + mkdir -p "${LOGDIR}" + if [ ! -e "${LOGDIR}" ] + then + echo + echo "Creating ${LOGDIR} directory failed." + echo + exit 1 + fi +fi +setfacl -m u:system:rwx "${LOGDIR}" + +# Check for ${RUNDIR} directory + +if [ -e "${RUNDIR}" -a ! -d "${RUNDIR}" ] +then + echo + echo "${RUNDIR} is existant but not a directory." + echo "syslogging using syslog-ng will not work." + echo + exit 1 +fi + +# Create it if necessary + +if [ ! -e "${RUNDIR}" ] +then + mkdir -p "${RUNDIR}" + if [ ! -e "${RUNDIR}" ] + then + echo + echo "Creating ${RUNDIR} directory failed." + echo + exit 1 + fi +fi +setfacl -m u:system:rwx "${RUNDIR}" + +# Check if syslog-ng.conf exists. If yes, ask for overwriting + +if [ -f "${SYSCONFDIR}/syslog-ng.conf" ] +then + if request "Overwrite existing ${SYSCONFDIR}/syslog-ng.conf file?" + then + rm -f "${SYSCONFDIR}/syslog-ng.conf" + if [ -f "${SYSCONFDIR}/syslog-ng.conf" ] + then + echo "Can't overwrite. ${SYSCONFDIR}/syslog-ng.conf is write protected." + fi + fi +fi + +if [ ! -f "${SYSCONFDIR}/syslog-ng.conf" ] +then + echo "Creating default ${SYSCONFDIR}/syslog-ng.conf file" + cat > ${SYSCONFDIR}/syslog-ng.conf << EOF +options { + keep_hostname(yes); + chain_hostnames(no); + owner("system"); + group("root"); + perm(0664); + sync(0); +}; + +source applications { + unix-dgram("/dev/log"); + internal(); +}; + +source kernel { + file("/dev/kmsg", log_prefix("kernel: ")); +}; + +destination messages { + file("/var/log/messages"); +}; + +log { + source(applications); + destination(messages); +}; + +log { + source(kernel); + destination(messages); +}; +EOF +fi +setfacl -m u:system:rw- "${SYSCONFDIR}/syslog-ng.conf" + +# Check if running on NT +_sys="`uname`" +_nt=`expr "${_sys}" : "CYGWIN_NT"` +# On NT ask if syslog-ng should be installed as service +if [ ${_nt} -gt 0 ] +then + # Check if syslogd is installed and remove on user request. + if cygrunsrv -Q syslogd > /dev/null 2>&1 + then + echo "Warning: The syslogd service is already installed. You can not" + echo "run both, syslogd and syslog-ng in parallel." + echo + if request "Do you want to deinstall the syslogd service in favor of syslog-ng?" + then + cygrunsrv -E syslogd + cygrunsrv -R syslogd + fi + fi + # Install syslog-ng service if it is not already installed + if ! cygrunsrv -Q syslog-ng > /dev/null 2>&1 + then + echo + echo + echo "Warning: The following function requires administrator privileges!" + echo + echo "Do you want to install syslog-ng as service?" + if request "(Say \"no\" if it's already installed as service)" + then + if cygrunsrv -I syslog-ng -d "CYGWIN syslog-ng" -p /usr/sbin/syslog-ng -a -F + then + echo + echo "The service has been installed under LocalSystem account." + echo "To start the service, call \`net start syslog-ng' or \`cygrunsrv -S syslog-ng'." + echo + echo "Check ${SYSCONFDIR}/syslog-ng.conf first, if it suits your needs." + fi + fi + fi +fi + +echo +echo "Configuration finished. Have fun!" Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat
Ping? Btw., my signed CLA should be in your (snail-)mailbox. Corinna On Jan 14 17:09, Corinna Vinschen wrote:
On Jan 14 15:18, Balazs Scheidler wrote:
On Mon, 2008-01-14 at 14:51 +0100, Corinna Vinschen wrote:
Would it be ok to add a contrib/cygwin subdir with these two scripts upstream? I have send the CLA to our legal dept but this might take some time. So I was wondering... do I need the CLA for the stuff under contrib as well?
No, contrib is for contributions, they are redistributed with the Premium Edition of syslog-ng, but in source format.
So if you submit patches against contrib/, I'm going to include that, and you don't need a CLA.
Thank you. It's always nice to be able to build upstream without having to tweak anything locally :)
Here is a ChangeLog and the diff
* contrib/cygwin-packaging/cygwin-postinstall: New script for packing Cygwin net distribution. * contrib/cygwin-packaging/syslog-ng-config: New script for run-time configuration of syslog-ng as part of a Cygwin net distribution.
diff --git a/contrib/cygwin-packaging/cygwin-postinstall b/contrib/cygwin-packaging/cygwin-postinstall new file mode 100755 index 0000000..85daf28 --- /dev/null +++ b/contrib/cygwin-packaging/cygwin-postinstall @@ -0,0 +1,57 @@ +#!/bin/sh +DESTDIR="" +if [ -n "$1" ] +then + DESTDIR=$1 +fi +if [ ! -d "contrib/cygwin-packaging" ] +then + echo "Please run 'contrib/cygwin-packaging/cygwin-postinstall' from the top-level source directory." + exit 1 +fi +if [ ! -f "${DESTDIR}/usr/sbin/syslog-ng.exe" ] +then + echo "Please run 'make install-strip' first." + exit 2 +fi +if [ ! -f "config.log" ] +then + echo "Please run './configure' first." + echo "Have a look into 'contrib/cygwin-packaging/cygwin-postinstall' how to do it." + exit 3 +fi +mkdir -p "${DESTDIR}/usr/bin" +mkdir -p "${DESTDIR}/usr/share/doc/syslog-ng" +mkdir -p "${DESTDIR}/usr/share/doc/Cygwin" +cp contrib/cygwin-packaging/syslog-ng-config "${DESTDIR}/usr/bin" +cp -rp doc/examples/syslog-ng.conf.s* doc/reference/syslog-ng.[tx]* "${DESTDIR}/usr/share/doc/syslog-ng" +tar xzfC doc/reference/syslog-ng.html.tar.gz "${DESTDIR}/usr/share/doc/syslog-ng" +cat > "${DESTDIR}/usr/share/doc/Cygwin/syslog-ng.README" <<'EOF' +If you want to use syslog-ng, just run the /usr/bin/syslog-ng-config +script. This script will create a default configuration file +/etc/syslog-ng.conf and it will install syslog-ng as a service on NT +systems on request. + +Please note that you cannot use syslogd from the inetutils package +and syslog-ng together. Only one syslog daemon should run at a time. +The syslog-ng-config script, as well as the latest version of the +syslogd-config script are taking care of this when requested to install +as service. + +The syslog-ng package has been built using the following command +sequence from the top level source dir: + +./configure \ + --disable-ipv6 \ + --disable-tcp-wrapper \ + --prefix=/usr \ + --sysconfdir=/etc \ + --libexecdir='$(prefix)/sbin' \ + --localstatedir=/var \ + --datadir='$(prefix)/share' \ + --mandir='$(prefix)/share/man' \ + --infodir='$(prefix)/share/info' +make +make install-strip +contrib/cygwin-packaging/cygwin-postinstall +EOF diff --git a/contrib/cygwin-packaging/syslog-ng-config b/contrib/cygwin-packaging/syslog-ng-config new file mode 100755 index 0000000..24738c5 --- /dev/null +++ b/contrib/cygwin-packaging/syslog-ng-config @@ -0,0 +1,284 @@ +#!/bin/sh +# +# syslog-ng-config, Copyright 2005, 2006 Corinna Vinschen +# +# This file is part of the Cygwin port of syslog-ng. + +# set -x + +# Subdirectory where the new package is being installed +PREFIX=/usr + +# Directory where the config files are stored +SYSCONFDIR=/etc +DEVDIR=/dev +LOGDIR=/var/log +RUNDIR=/var/run + +progname=$0 +auto_answer="" + +request() +{ + if [ "${auto_answer}" = "yes" ] + then + return 0 + elif [ "${auto_answer}" = "no" ] + then + return 1 + fi + + answer="" + while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ] + do + echo -n "$1 (yes/no) " + read answer + done + if [ "X${answer}" = "Xyes" ] + then + return 0 + else + return 1 + fi +} + +# Check options + +while : +do + case $# in + 0) + break + ;; + esac + + option=$1 + shift + + case "$option" in + -d | --debug ) + set -x + ;; + + -y | --yes ) + auto_answer=yes + ;; + + -n | --no ) + auto_answer=no + ;; + *) + echo "usage: ${progname} [OPTION]..." + echo + echo "This script creates a basic syslog-ng configuration." + echo + echo "Options:" + echo " --debug -d Enable shell's debug output." + echo " --yes -y Answer all questions with \"yes\" automatically." + echo " --no -n Answer all questions with \"no\" automatically." + echo + exit 1 + ;; + + esac +done + +# Check for ${SYSCONFDIR} directory + +if [ -e "${SYSCONFDIR}" -a ! -d "${SYSCONFDIR}" ] +then + echo + echo "${SYSCONFDIR} is existant but not a directory." + echo "Cannot create global configuration files." + echo + exit 1 +fi + +# Create it if necessary + +if [ ! -e "${SYSCONFDIR}" ] +then + mkdir "${SYSCONFDIR}" + if [ ! -e "${SYSCONFDIR}" ] + then + echo + echo "Creating ${SYSCONFDIR} directory failed." + echo + exit 1 + fi +fi +setfacl -m u:system:rwx "${SYSCONFDIR}" + +# Check for ${DEVDIR} directory + +if [ -e "${DEVDIR}" -a ! -d "${DEVDIR}" ] +then + echo + echo "${DEVDIR} is existant but not a directory." + echo "syslogging using syslog-ng will not work." + echo + exit 1 +fi + +# Create it if necessary + +if [ ! -e "${DEVDIR}" ] +then + mkdir "${DEVDIR}" + if [ ! -e "${DEVDIR}" ] + then + echo + echo "Creating ${DEVDIR} directory failed." + echo + exit 1 + fi +fi +setfacl -m u:system:rwx "${DEVDIR}" + +# Check for ${LOGDIR} directory + +if [ -e "${LOGDIR}" -a ! -d "${LOGDIR}" ] +then + echo + echo "${LOGDIR} is existant but not a directory." + echo "syslogging using syslog-ng will not work." + echo + exit 1 +fi + +# Create it if necessary + +if [ ! -e "${LOGDIR}" ] +then + mkdir -p "${LOGDIR}" + if [ ! -e "${LOGDIR}" ] + then + echo + echo "Creating ${LOGDIR} directory failed." + echo + exit 1 + fi +fi +setfacl -m u:system:rwx "${LOGDIR}" + +# Check for ${RUNDIR} directory + +if [ -e "${RUNDIR}" -a ! -d "${RUNDIR}" ] +then + echo + echo "${RUNDIR} is existant but not a directory." + echo "syslogging using syslog-ng will not work." + echo + exit 1 +fi + +# Create it if necessary + +if [ ! -e "${RUNDIR}" ] +then + mkdir -p "${RUNDIR}" + if [ ! -e "${RUNDIR}" ] + then + echo + echo "Creating ${RUNDIR} directory failed." + echo + exit 1 + fi +fi +setfacl -m u:system:rwx "${RUNDIR}" + +# Check if syslog-ng.conf exists. If yes, ask for overwriting + +if [ -f "${SYSCONFDIR}/syslog-ng.conf" ] +then + if request "Overwrite existing ${SYSCONFDIR}/syslog-ng.conf file?" + then + rm -f "${SYSCONFDIR}/syslog-ng.conf" + if [ -f "${SYSCONFDIR}/syslog-ng.conf" ] + then + echo "Can't overwrite. ${SYSCONFDIR}/syslog-ng.conf is write protected." + fi + fi +fi + +if [ ! -f "${SYSCONFDIR}/syslog-ng.conf" ] +then + echo "Creating default ${SYSCONFDIR}/syslog-ng.conf file" + cat > ${SYSCONFDIR}/syslog-ng.conf << EOF +options { + keep_hostname(yes); + chain_hostnames(no); + owner("system"); + group("root"); + perm(0664); + sync(0); +}; + +source applications { + unix-dgram("/dev/log"); + internal(); +}; + +source kernel { + file("/dev/kmsg", log_prefix("kernel: ")); +}; + +destination messages { + file("/var/log/messages"); +}; + +log { + source(applications); + destination(messages); +}; + +log { + source(kernel); + destination(messages); +}; +EOF +fi +setfacl -m u:system:rw- "${SYSCONFDIR}/syslog-ng.conf" + +# Check if running on NT +_sys="`uname`" +_nt=`expr "${_sys}" : "CYGWIN_NT"` +# On NT ask if syslog-ng should be installed as service +if [ ${_nt} -gt 0 ] +then + # Check if syslogd is installed and remove on user request. + if cygrunsrv -Q syslogd > /dev/null 2>&1 + then + echo "Warning: The syslogd service is already installed. You can not" + echo "run both, syslogd and syslog-ng in parallel." + echo + if request "Do you want to deinstall the syslogd service in favor of syslog-ng?" + then + cygrunsrv -E syslogd + cygrunsrv -R syslogd + fi + fi + # Install syslog-ng service if it is not already installed + if ! cygrunsrv -Q syslog-ng > /dev/null 2>&1 + then + echo + echo + echo "Warning: The following function requires administrator privileges!" + echo + echo "Do you want to install syslog-ng as service?" + if request "(Say \"no\" if it's already installed as service)" + then + if cygrunsrv -I syslog-ng -d "CYGWIN syslog-ng" -p /usr/sbin/syslog-ng -a -F + then + echo + echo "The service has been installed under LocalSystem account." + echo "To start the service, call \`net start syslog-ng' or \`cygrunsrv -S syslog-ng'." + echo + echo "Check ${SYSCONFDIR}/syslog-ng.conf first, if it suits your needs." + fi + fi + fi +fi + +echo +echo "Configuration finished. Have fun!"
Corinna
-- Corinna Vinschen Cygwin Project Co-Leader Red Hat _______________________________________________ syslog-ng maillist - syslog-ng@lists.balabit.hu https://lists.balabit.hu/mailman/listinfo/syslog-ng Frequently asked questions at http://www.campin.net/syslog-ng/faq.html
-- Corinna Vinschen Cygwin Project Co-Leader Red Hat
On Mon, 2008-01-21 at 12:53 +0100, Corinna Vinschen wrote:
Ping?
Btw., my signed CLA should be in your (snail-)mailbox.
Did you fax it or really sent it by snail mail? I haven't seen the fax though, but I'm going to look into this. Thanks. -- Bazsi
Hi Balazs, On Jan 27 20:20, Balazs Scheidler wrote:
On Mon, 2008-01-21 at 12:53 +0100, Corinna Vinschen wrote:
Ping?
Btw., my signed CLA should be in your (snail-)mailbox.
Did you fax it or really sent it by snail mail? I haven't seen the fax though, but I'm going to look into this.
I snail mailed it last Monday. Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat
On Mon, 2008-01-14 at 17:09 +0100, Corinna Vinschen wrote:
On Jan 14 15:18, Balazs Scheidler wrote:
On Mon, 2008-01-14 at 14:51 +0100, Corinna Vinschen wrote:
Would it be ok to add a contrib/cygwin subdir with these two scripts upstream? I have send the CLA to our legal dept but this might take some time. So I was wondering... do I need the CLA for the stuff under contrib as well?
No, contrib is for contributions, they are redistributed with the Premium Edition of syslog-ng, but in source format.
So if you submit patches against contrib/, I'm going to include that, and you don't need a CLA.
Thank you. It's always nice to be able to build upstream without having to tweak anything locally :)
Commited, thanks. -- Bazsi
On Jan 27 20:19, Balazs Scheidler wrote:
On Mon, 2008-01-14 at 17:09 +0100, Corinna Vinschen wrote:
Thank you. It's always nice to be able to build upstream without having to tweak anything locally :)
Commited, thanks.
Thank you! Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat
participants (2)
-
Balazs Scheidler
-
Corinna Vinschen