[syslog-ng] Localport() & localip() - numeric port now works
simonst at wellsfargo.com
simonst at wellsfargo.com
Thu Apr 5 00:31:35 CEST 2007
Your second patch fixed the problem - localport() now accepts either numeric
or /etc/service names. I also combined both patches into a single one for
my rpm:
--- syslog-ng-2.0.2/src/cfg-grammar.y.orig 2007-04-04
13:40:41.000000000 -0700
+++ syslog-ng-2.0.2/src/cfg-grammar.y 2007-04-04 14:44:54.000000000 -0700
@@ -369,14 +369,12 @@
source_afinet_udp_option
: source_afinet_option
- | KW_LOCALPORT '(' string ')' {
afinet_sd_set_localport(last_driver, 0, $3, "udp"); free($3); }
- | KW_PORT '(' string ')' {
afinet_sd_set_localport(last_driver, 0, $3, "udp"); free($3); }
+ | KW_LOCALPORT '(' string_or_number ')' {
afinet_sd_set_localport(last_driver, $3, "udp"); free($3); }
+ | KW_PORT '(' string_or_number ')' {
afinet_sd_set_localport(last_driver, $3, "udp"); free($3); }
;
source_afinet_option
- : KW_LOCALIP '(' string ')' {
afinet_sd_set_localip(last_driver, $3); free($3); }
- | KW_LOCALPORT '(' NUMBER ')' {
afinet_sd_set_localport(last_driver, $3, NULL, NULL); }
- | KW_PORT '(' NUMBER ')' {
afinet_sd_set_localport(last_driver, $3, NULL, NULL); }
+ : KW_LOCALIP '(' string')' {
afinet_sd_set_localip(last_driver, $3); free($3); }
| KW_IP '(' string ')' {
afinet_sd_set_localip(last_driver, $3); free($3); }
| source_reader_option
| inet_socket_option
@@ -401,8 +399,8 @@
source_afinet_tcp_option
: source_afinet_option
- | KW_LOCALPORT '(' string ')' {
afinet_sd_set_localport(last_driver, 0, $3, "tcp"); free($3); }
- | KW_PORT '(' string ')' {
afinet_sd_set_localport(last_driver, 0, $3, "tcp"); free($3); }
+ | KW_LOCALPORT '(' string_or_number ')' {
afinet_sd_set_localport(last_driver, $3, "tcp"); free($3); }
+ | KW_PORT '(' string_or_number ')' {
afinet_sd_set_localport(last_driver, $3, "tcp"); free($3); }
| source_afsocket_stream_params {}
;
@@ -596,16 +594,15 @@
dest_afinet_option
: KW_LOCALIP '(' string ')' {
afinet_dd_set_localip(last_driver, $3); free($3); }
- | KW_PORT '(' NUMBER ')' {
afinet_dd_set_destport(last_driver, $3, NULL, NULL); }
| inet_socket_option
| dest_writer_option
;
dest_afinet_udp_option
: dest_afinet_option
- | KW_LOCALPORT '(' string ')' {
afinet_dd_set_localport(last_driver, 0, $3, "udp"); free($3); }
- | KW_PORT '(' string ')' {
afinet_dd_set_destport(last_driver, 0, $3, "udp"); free($3); }
- | KW_DESTPORT '(' string ')' {
afinet_dd_set_destport(last_driver, 0, $3, "udp"); free($3); }
+ | KW_LOCALPORT '(' string_or_number ')' {
afinet_dd_set_localport(last_driver, $3, "udp"); free($3); }
+ | KW_PORT '(' string_or_number ')' {
afinet_dd_set_destport(last_driver, $3, "udp"); free($3); }
+ | KW_DESTPORT '(' string_or_number ')' {
afinet_dd_set_destport(last_driver, $3, "udp"); free($3); }
;
dest_afinet_tcp_params
@@ -628,9 +625,9 @@
dest_afinet_tcp_option
: dest_afinet_option
- | KW_LOCALPORT '(' string ')' {
afinet_dd_set_localport(last_driver, 0, $3, "tcp"); free($3); }
- | KW_PORT '(' string ')' {
afinet_dd_set_destport(last_driver, 0, $3, "tcp"); free($3); }
- | KW_DESTPORT '(' string ')' {
afinet_dd_set_destport(last_driver, 0, $3, "tcp"); free($3); }
+ | KW_LOCALPORT '(' string_or_number ')' {
afinet_dd_set_localport(last_driver, $3, "tcp"); free($3); }
+ | KW_PORT '(' string_or_number ')' {
afinet_dd_set_destport(last_driver, $3, "tcp"); free($3); }
+ | KW_DESTPORT '(' string_or_number ')' {
afinet_dd_set_destport(last_driver, $3, "tcp"); free($3); }
/*
| KW_MAC '(' yesno ')'
| KW_AUTH '(' yesno ')'
@@ -904,4 +901,4 @@
last_reader_options = NULL;
last_writer_options = NULL;
last_template = NULL;
-}
\ No newline at end of file
+}
--- syslog-ng-2.0.2/src/afinet.c.orig 2006-06-01 02:14:39.000000000 -0700
+++ syslog-ng-2.0.2/src/afinet.c 2007-04-04 14:18:44.000000000 -0700
@@ -40,14 +40,20 @@
static void
-afinet_set_port(GSockAddr *addr, gint port, gchar *service, gchar *proto)
+afinet_set_port(GSockAddr *addr, gchar *service, gchar *proto)
{
if (addr)
{
- if (proto)
+ gchar *end;
+ gint port;
+
+ /* check if service is numeric */
+ port = strtol(service, &end, 10);
+ if ((*end != 0))
{
struct servent *se;
+ /* service is not numeric, check if it's a service in
/etc/services */
se = getservbyname(service, proto);
if (se)
{
@@ -217,11 +223,11 @@
}
void
-afinet_sd_set_localport(LogDriver *s, gint port, gchar *service, gchar
*proto)
+afinet_sd_set_localport(LogDriver *s, gchar *service, gchar *proto)
{
AFSocketSourceDriver *self = (AFSocketSourceDriver *) s;
- afinet_set_port(self->bind_addr, port, service, proto);
+ afinet_set_port(self->bind_addr, service, proto);
}
void
@@ -270,19 +276,19 @@
/* afinet destination */
void
-afinet_dd_set_localport(LogDriver *s, gint port, gchar *service, gchar
*proto)
+afinet_dd_set_localport(LogDriver *s, gchar *service, gchar *proto)
{
AFInetDestDriver *self = (AFInetDestDriver *) s;
- afinet_set_port(self->super.bind_addr, port, service, proto);
+ afinet_set_port(self->super.bind_addr, service, proto);
}
void
-afinet_dd_set_destport(LogDriver *s, gint port, gchar *service, gchar
*proto)
+afinet_dd_set_destport(LogDriver *s, gchar *service, gchar *proto)
{
AFInetDestDriver *self = (AFInetDestDriver *) s;
- afinet_set_port(self->super.dest_addr, port, service, proto);
+ afinet_set_port(self->super.dest_addr, service, proto);
}
void
--- syslog-ng-2.0.2/src/afinet.h.orig 2006-04-30 15:42:15.000000000 -0700
+++ syslog-ng-2.0.2/src/afinet.h 2007-04-04 14:18:44.000000000 -0700
@@ -40,7 +40,7 @@
} AFInetSourceDriver;
LogDriver *afinet_sd_new(gint af, gchar *host, gint port, guint flags);
-void afinet_sd_set_localport(LogDriver *self, gint port, gchar *service,
gchar *proto);
+void afinet_sd_set_localport(LogDriver *self, gchar *service, gchar
*proto);
void afinet_sd_set_localip(LogDriver *self, gchar *ip);
#define afinet_sd_set_auth(a,b)
@@ -54,8 +54,8 @@
} AFInetDestDriver;
LogDriver *afinet_dd_new(gint af, gchar *host, gint port, guint flags);
-void afinet_dd_set_localport(LogDriver *self, gint port, gchar *service,
gchar *proto);
-void afinet_dd_set_destport(LogDriver *self, gint port, gchar *service,
gchar *proto);
+void afinet_dd_set_localport(LogDriver *self, gchar *service, gchar
*proto);
+void afinet_dd_set_destport(LogDriver *self, gchar *service, gchar *proto);
void afinet_dd_set_localip(LogDriver *self, gchar *ip);
void afinet_dd_set_sync_freq(LogDriver *self, gint sync_freq);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5621 bytes
Desc: not available
Url : http://lists.balabit.hu/pipermail/syslog-ng/attachments/20070404/8e38db99/smime-0001.bin
More information about the syslog-ng
mailing list