Re: s6-socklog with -i ipport option
jkampe <[email protected]> Thu, 8 Aug 2024 23:22:13 +0300
| Newsgroups | gmane.comp.sysutils.supervision.general |
|---|---|
| Organization | gmail.com |
| Message-ID | <[email protected]> |
Replying to myself after looking at the code ;) Seems ip address gets overwritten with port number while formatting the ip_port string. Maybe fix it with something like attached patch. -Jan On Tue, 6 Aug 2024 21:37:43 +0300 Jan Kämpe <[email protected]> wrote: > The clientip_clientport output seem incorrect in s6-socklog output when > using "-i ipport" option. > Example to reproduce; run > $ s6-socklog -i 192.168.21.1:10514 > > Then send test syslog message to s6-socklog listening on the UDP port > (here using "logger" on x86_64 debian linux) > $ logger -n 192.168.21.1 -P 10514 "Sample log message" > > The (start of) s6-socklog produced log line "clientip_clientport" looks > (usually) something like this: > 5511368.21.1_: user.notice: > > Can anyone else try to re-produce/confirm? > > -J
001-fix-socklog-ipaddr-fmt.patch
(text/x-diff, 672 B)
diff -up s6-2.13.0.0/src/daemontools-extras/s6-socklog.c.orig s6-2.13.0.0/src/daemontools-extras/s6-socklog.c
--- s6-2.13.0.0/src/daemontools-extras/s6-socklog.c.orig 2024-08-08 21:45:07.257448848 +0300
+++ s6-2.13.0.0/src/daemontools-extras/s6-socklog.c 2024-08-08 21:46:02.416505236 +0300
@@ -194,7 +194,7 @@ int main (int argc, char const *const *a
char fmt[IP46_FMT + UINT16_FMT + 3] ;
size_t m = ip46_fmt(fmt, &ip) ;
fmt[m++] = '_' ;
- m += uint16_fmt(fmt, port) ;
+ m += uint16_fmt(&fmt[m], port) ;
fmt[m++] = ':' ; fmt[m++] = ' ' ;
buffer_putnoflush(&b1, fmt, m) ;
}