From 610e83cbbfe8a3fe223026a07896a95cb5959cc7 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 27 Aug 2024 14:02:20 +0200 Subject: [PATCH] patches/syslogd: backport fixes to listen .conf directive Signed-off-by: Joachim Wiberg --- ...f-raw-kernel-log-messages-to-console.patch | 2 +- ...l-log-rotation-options-to-.conf-file.patch | 2 +- ...-global-file-rotation-if-not-set-per.patch | 2 +- ...otation-settings-to-set-only-one-val.patch | 2 +- ...locking-delay-for-unreachable-remote.patch | 2 +- ...-annoying-gcc-warning-in-rotate_file.patch | 2 +- ...-cfparse-to-add-a-per-keyword-parser.patch | 2 +- .../0008-Fix-gcc-warning-in-vsyslogp_r.patch | 2 +- ...rt-for-listen-addr-port-to-.conf-fil.patch | 2 +- ...ating-UNIX-and-network-sockets-on-fa.patch | 2 +- ...iles-from-include-directories-sorted.patch | 2 +- .../0012-Fix-87-segfault-on-shutdown.patch | 2 +- ...to-remote-IPv6-address-does-not-work.patch | 2 +- ...pt-facilities-for-RFC5424-compliance.patch | 2 +- ...delay-for-unresolvable-remote-target.patch | 2 +- ...uption-using-.conf-file-listen-direc.patch | 123 ++++++++++++++++++ ...rt-for-IPv6-addresses-in-listen-dire.patch | 47 +++++++ 17 files changed, 185 insertions(+), 15 deletions(-) create mode 100644 patches/sysklogd/2.5.2/0016-Fix-89-data-corruption-using-.conf-file-listen-direc.patch create mode 100644 patches/sysklogd/2.5.2/0017-Fix-90-add-support-for-IPv6-addresses-in-listen-dire.patch diff --git a/patches/sysklogd/2.5.2/0001-Fix-72-loss-of-raw-kernel-log-messages-to-console.patch b/patches/sysklogd/2.5.2/0001-Fix-72-loss-of-raw-kernel-log-messages-to-console.patch index d6033dd4..ed64cf3f 100644 --- a/patches/sysklogd/2.5.2/0001-Fix-72-loss-of-raw-kernel-log-messages-to-console.patch +++ b/patches/sysklogd/2.5.2/0001-Fix-72-loss-of-raw-kernel-log-messages-to-console.patch @@ -1,7 +1,7 @@ From ad9a464806fe27fe65d403f56f1dc701f7d0a10a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 24 Apr 2024 13:19:09 +0200 -Subject: [PATCH 01/15] Fix #72: loss of raw kernel log messages to console +Subject: [PATCH 01/17] Fix #72: loss of raw kernel log messages to console Organization: Addiva Elektronik This patch adds a command line flag `-l` to keep kernel logs to console. diff --git a/patches/sysklogd/2.5.2/0002-Fix-80-add-global-log-rotation-options-to-.conf-file.patch b/patches/sysklogd/2.5.2/0002-Fix-80-add-global-log-rotation-options-to-.conf-file.patch index 76e8fe73..074dddbd 100644 --- a/patches/sysklogd/2.5.2/0002-Fix-80-add-global-log-rotation-options-to-.conf-file.patch +++ b/patches/sysklogd/2.5.2/0002-Fix-80-add-global-log-rotation-options-to-.conf-file.patch @@ -1,7 +1,7 @@ From 7e0882688b0ea459c850e6e0ace66cca7100fd0a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 12 Jul 2024 22:54:51 +0200 -Subject: [PATCH 02/15] Fix #80: add global log rotation options to .conf file +Subject: [PATCH 02/17] Fix #80: add global log rotation options to .conf file Organization: Addiva Elektronik Signed-off-by: Joachim Wiberg diff --git a/patches/sysklogd/2.5.2/0003-Refactor-rely-on-global-file-rotation-if-not-set-per.patch b/patches/sysklogd/2.5.2/0003-Refactor-rely-on-global-file-rotation-if-not-set-per.patch index 6bd0a0e5..7a488086 100644 --- a/patches/sysklogd/2.5.2/0003-Refactor-rely-on-global-file-rotation-if-not-set-per.patch +++ b/patches/sysklogd/2.5.2/0003-Refactor-rely-on-global-file-rotation-if-not-set-per.patch @@ -1,7 +1,7 @@ From a2c47f81bf3d358dddb475cbaa8125f2cb776587 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 14 Jul 2024 09:19:01 +0200 -Subject: [PATCH 03/15] Refactor, rely on global file rotation if not set +Subject: [PATCH 03/17] Refactor, rely on global file rotation if not set per-file Organization: Addiva Elektronik diff --git a/patches/sysklogd/2.5.2/0004-Allow-per-file-rotation-settings-to-set-only-one-val.patch b/patches/sysklogd/2.5.2/0004-Allow-per-file-rotation-settings-to-set-only-one-val.patch index c382c842..79561209 100644 --- a/patches/sysklogd/2.5.2/0004-Allow-per-file-rotation-settings-to-set-only-one-val.patch +++ b/patches/sysklogd/2.5.2/0004-Allow-per-file-rotation-settings-to-set-only-one-val.patch @@ -1,7 +1,7 @@ From 0366909927cebecdf6c35b83a976a25c529043e1 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 14 Jul 2024 09:26:50 +0200 -Subject: [PATCH 04/15] Allow per-file rotation settings to set only one value +Subject: [PATCH 04/17] Allow per-file rotation settings to set only one value Organization: Addiva Elektronik This change makes it possible to set rotate=2M, or rotate=:5, and then diff --git a/patches/sysklogd/2.5.2/0005-Fix-81-blocking-delay-for-unreachable-remote.patch b/patches/sysklogd/2.5.2/0005-Fix-81-blocking-delay-for-unreachable-remote.patch index 27294d46..27572d00 100644 --- a/patches/sysklogd/2.5.2/0005-Fix-81-blocking-delay-for-unreachable-remote.patch +++ b/patches/sysklogd/2.5.2/0005-Fix-81-blocking-delay-for-unreachable-remote.patch @@ -1,7 +1,7 @@ From a1dc835fd5d11ce0dd6d9983c1aa2ca188460ac9 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 14 Jul 2024 17:46:41 +0200 -Subject: [PATCH 05/15] Fix #81: blocking delay for unreachable remote +Subject: [PATCH 05/17] Fix #81: blocking delay for unreachable remote Organization: Addiva Elektronik This patch fixes a blocking delay when a named remote action is set up. diff --git a/patches/sysklogd/2.5.2/0006-Fix-annoying-gcc-warning-in-rotate_file.patch b/patches/sysklogd/2.5.2/0006-Fix-annoying-gcc-warning-in-rotate_file.patch index 5b988209..043594c4 100644 --- a/patches/sysklogd/2.5.2/0006-Fix-annoying-gcc-warning-in-rotate_file.patch +++ b/patches/sysklogd/2.5.2/0006-Fix-annoying-gcc-warning-in-rotate_file.patch @@ -1,7 +1,7 @@ From 2d626af27e8f3115175749d183a8b7f91849bf10 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 14 Jul 2024 17:43:39 +0200 -Subject: [PATCH 06/15] Fix annoying gcc warning in rotate_file() +Subject: [PATCH 06/17] Fix annoying gcc warning in rotate_file() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/patches/sysklogd/2.5.2/0007-Refactor-cfparse-to-add-a-per-keyword-parser.patch b/patches/sysklogd/2.5.2/0007-Refactor-cfparse-to-add-a-per-keyword-parser.patch index 2c4d4dc4..aeac1967 100644 --- a/patches/sysklogd/2.5.2/0007-Refactor-cfparse-to-add-a-per-keyword-parser.patch +++ b/patches/sysklogd/2.5.2/0007-Refactor-cfparse-to-add-a-per-keyword-parser.patch @@ -1,7 +1,7 @@ From 2aa73f85580614b9162aaaa74b2a9e817c6396bd Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 15 Jul 2024 10:46:50 +0200 -Subject: [PATCH 07/15] Refactor cfparse() to add a per-keyword parser +Subject: [PATCH 07/17] Refactor cfparse() to add a per-keyword parser Organization: Addiva Elektronik Signed-off-by: Joachim Wiberg diff --git a/patches/sysklogd/2.5.2/0008-Fix-gcc-warning-in-vsyslogp_r.patch b/patches/sysklogd/2.5.2/0008-Fix-gcc-warning-in-vsyslogp_r.patch index 22e4de08..644077b6 100644 --- a/patches/sysklogd/2.5.2/0008-Fix-gcc-warning-in-vsyslogp_r.patch +++ b/patches/sysklogd/2.5.2/0008-Fix-gcc-warning-in-vsyslogp_r.patch @@ -1,7 +1,7 @@ From c15bb6208cdd0e0629a28c10cb448a11aa7a1624 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 15 Jul 2024 14:24:08 +0200 -Subject: [PATCH 08/15] Fix gcc warning in vsyslogp_r() +Subject: [PATCH 08/17] Fix gcc warning in vsyslogp_r() Organization: Addiva Elektronik Signed-off-by: Joachim Wiberg diff --git a/patches/sysklogd/2.5.2/0009-Fix-83-add-support-for-listen-addr-port-to-.conf-fil.patch b/patches/sysklogd/2.5.2/0009-Fix-83-add-support-for-listen-addr-port-to-.conf-fil.patch index 9955c07d..06bd487a 100644 --- a/patches/sysklogd/2.5.2/0009-Fix-83-add-support-for-listen-addr-port-to-.conf-fil.patch +++ b/patches/sysklogd/2.5.2/0009-Fix-83-add-support-for-listen-addr-port-to-.conf-fil.patch @@ -1,7 +1,7 @@ From f5fae387b92e81cc1f1f9e8f6656b20bb9e2e929 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 15 Jul 2024 14:57:54 +0200 -Subject: [PATCH 09/15] Fix #83: add support for listen addr:port to .conf file +Subject: [PATCH 09/17] Fix #83: add support for listen addr:port to .conf file Organization: Addiva Elektronik This complements the command line '-b addr:port' support with a 'listen' diff --git a/patches/sysklogd/2.5.2/0010-Fix-82-retry-creating-UNIX-and-network-sockets-on-fa.patch b/patches/sysklogd/2.5.2/0010-Fix-82-retry-creating-UNIX-and-network-sockets-on-fa.patch index 70b3c0de..c7097cba 100644 --- a/patches/sysklogd/2.5.2/0010-Fix-82-retry-creating-UNIX-and-network-sockets-on-fa.patch +++ b/patches/sysklogd/2.5.2/0010-Fix-82-retry-creating-UNIX-and-network-sockets-on-fa.patch @@ -1,7 +1,7 @@ From ad8dedd04a979279d245b53a60311ad91acaaf14 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 15 Jul 2024 15:02:32 +0200 -Subject: [PATCH 10/15] Fix #82: retry creating UNIX and network sockets on +Subject: [PATCH 10/17] Fix #82: retry creating UNIX and network sockets on failure Organization: Addiva Elektronik diff --git a/patches/sysklogd/2.5.2/0011-Read-.conf-files-from-include-directories-sorted.patch b/patches/sysklogd/2.5.2/0011-Read-.conf-files-from-include-directories-sorted.patch index 940977a5..b7a950e4 100644 --- a/patches/sysklogd/2.5.2/0011-Read-.conf-files-from-include-directories-sorted.patch +++ b/patches/sysklogd/2.5.2/0011-Read-.conf-files-from-include-directories-sorted.patch @@ -1,7 +1,7 @@ From 87ccd3eb37087ffb4b5f5b0322a558522a705215 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 18 Jul 2024 11:42:36 +0200 -Subject: [PATCH 11/15] Read *.conf files from include/ directories sorted +Subject: [PATCH 11/17] Read *.conf files from include/ directories sorted Organization: Addiva Elektronik No point in "saving time" on this operation. It is more important to diff --git a/patches/sysklogd/2.5.2/0012-Fix-87-segfault-on-shutdown.patch b/patches/sysklogd/2.5.2/0012-Fix-87-segfault-on-shutdown.patch index 0f8dbb73..42b06c67 100644 --- a/patches/sysklogd/2.5.2/0012-Fix-87-segfault-on-shutdown.patch +++ b/patches/sysklogd/2.5.2/0012-Fix-87-segfault-on-shutdown.patch @@ -1,7 +1,7 @@ From 035dccad53efcd4237f040dc702ab435212ecf03 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 21 Jul 2024 19:15:48 +0200 -Subject: [PATCH 12/15] Fix #87: segfault on shutdown +Subject: [PATCH 12/17] Fix #87: segfault on shutdown Organization: Addiva Elektronik Regression introduced in in 36295e3, for issue #82. diff --git a/patches/sysklogd/2.5.2/0013-Fix-85-logging-to-remote-IPv6-address-does-not-work.patch b/patches/sysklogd/2.5.2/0013-Fix-85-logging-to-remote-IPv6-address-does-not-work.patch index d68a9e57..dc0d20c5 100644 --- a/patches/sysklogd/2.5.2/0013-Fix-85-logging-to-remote-IPv6-address-does-not-work.patch +++ b/patches/sysklogd/2.5.2/0013-Fix-85-logging-to-remote-IPv6-address-does-not-work.patch @@ -1,7 +1,7 @@ From c7267011224ebd28d8a9daccd589109288fbde11 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 26 Aug 2024 11:47:10 +0200 -Subject: [PATCH 13/15] Fix #85: logging to remote IPv6 address does not work +Subject: [PATCH 13/17] Fix #85: logging to remote IPv6 address does not work Organization: Addiva Elektronik Signed-off-by: Joachim Wiberg diff --git a/patches/sysklogd/2.5.2/0014-Fix-86-adapt-facilities-for-RFC5424-compliance.patch b/patches/sysklogd/2.5.2/0014-Fix-86-adapt-facilities-for-RFC5424-compliance.patch index babc044c..55df3b30 100644 --- a/patches/sysklogd/2.5.2/0014-Fix-86-adapt-facilities-for-RFC5424-compliance.patch +++ b/patches/sysklogd/2.5.2/0014-Fix-86-adapt-facilities-for-RFC5424-compliance.patch @@ -1,7 +1,7 @@ From 1a2e13cb3f3e4fb9f33a56cc87fb96ebc3bb45c7 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 26 Aug 2024 11:49:27 +0200 -Subject: [PATCH 14/15] Fix #86: adapt facilities for RFC5424 compliance +Subject: [PATCH 14/17] Fix #86: adapt facilities for RFC5424 compliance Organization: Addiva Elektronik Signed-off-by: Joachim Wiberg diff --git a/patches/sysklogd/2.5.2/0015-Fix-88-initial-delay-for-unresolvable-remote-target.patch b/patches/sysklogd/2.5.2/0015-Fix-88-initial-delay-for-unresolvable-remote-target.patch index e792755e..22b7d198 100644 --- a/patches/sysklogd/2.5.2/0015-Fix-88-initial-delay-for-unresolvable-remote-target.patch +++ b/patches/sysklogd/2.5.2/0015-Fix-88-initial-delay-for-unresolvable-remote-target.patch @@ -1,7 +1,7 @@ From d6e7d2c6ee36cfc67eeef643d4a6c69dfbbd36ab Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 26 Aug 2024 11:50:13 +0200 -Subject: [PATCH 15/15] Fix #88: initial delay for unresolvable remote target +Subject: [PATCH 15/17] Fix #88: initial delay for unresolvable remote target Organization: Addiva Elektronik Signed-off-by: Joachim Wiberg diff --git a/patches/sysklogd/2.5.2/0016-Fix-89-data-corruption-using-.conf-file-listen-direc.patch b/patches/sysklogd/2.5.2/0016-Fix-89-data-corruption-using-.conf-file-listen-direc.patch new file mode 100644 index 00000000..d865d605 --- /dev/null +++ b/patches/sysklogd/2.5.2/0016-Fix-89-data-corruption-using-.conf-file-listen-direc.patch @@ -0,0 +1,123 @@ +From fbded7ec91a0747b4d9c9059ef48aebb5d5fc4e8 Mon Sep 17 00:00:00 2001 +From: Joachim Wiberg +Date: Tue, 27 Aug 2024 13:32:18 +0200 +Subject: [PATCH 16/17] Fix #89: data corruption using .conf file listen + directive +Organization: Addiva Elektronik + +The addpeer() function must save a copy of the name:service argument, +otherwise, when called from cfparse(), the contents of the string will +be corrupted. + +Also, add a delpeer() function to wrap the logic for when closing and +deleting peers when stopping or reloading syslogd. + +Signed-off-by: Joachim Wiberg +--- + src/syslogd.c | 47 +++++++++++++++++++++++++++++++++-------------- + src/syslogd.h | 4 ++-- + 2 files changed, 35 insertions(+), 16 deletions(-) + +diff --git a/src/syslogd.c b/src/syslogd.c +index fecf281..9b8dc24 100644 +--- a/src/syslogd.c ++++ b/src/syslogd.c +@@ -298,12 +298,43 @@ static int addpeer(struct peer *pe0) + pe = calloc(1, sizeof(*pe)); + if (pe == NULL) + err(1, "malloc failed"); ++ + *pe = *pe0; ++ if (pe0->pe_name) ++ pe->pe_name = strdup(pe0->pe_name); ++ if (pe0->pe_serv) ++ pe->pe_serv = strdup(pe0->pe_serv); ++ + TAILQ_INSERT_TAIL(&pqueue, pe, pe_link); + + return 0; + } + ++static void close_socket(struct peer *pe) ++{ ++ for (size_t i = 0; i < pe->pe_socknum; i++) { ++ if (pe->pe_mode & 01000) ++ NOTE("Closing inet socket %s:%s", pe->pe_name ?: "*", pe->pe_serv); ++ socket_close(pe->pe_sock[i]); ++ } ++ pe->pe_socknum = 0; ++} ++ ++static void delpeer(struct peer *pe) ++{ ++ if (!pe) ++ return; ++ ++ close_socket(pe); ++ ++ if (pe->pe_name) ++ free(pe->pe_name); ++ if (pe->pe_serv) ++ free(pe->pe_serv); ++ ++ free(pe); ++} ++ + static void sys_seqno_load(void) + { + char buf[32], *str; +@@ -938,16 +969,6 @@ static int create_inet_socket(struct peer *pe) + return 0; + } + +-static void close_socket(struct peer *pe) +-{ +- for (size_t i = 0; i < pe->pe_socknum; i++) { +- if (pe->pe_mode & 01000) +- NOTE("Closing inet socket %s:%s", pe->pe_name ?: "*", pe->pe_serv); +- socket_close(pe->pe_sock[i]); +- } +- pe->pe_socknum = 0; +-} +- + void untty(void) + { + #ifdef HAVE_SETSID +@@ -2589,8 +2610,7 @@ void die(int signo) + */ + TAILQ_FOREACH_SAFE(pe, &pqueue, pe_link, next) { + TAILQ_REMOVE(&pqueue, pe, pe_link); +- close_socket(pe); +- free(pe); ++ delpeer(pe); + } + + /* +@@ -2907,8 +2927,7 @@ static void init(void) + continue; + + TAILQ_REMOVE(&pqueue, pe, pe_link); +- close_socket(pe); +- free(pe); ++ delpeer(pe); + } + + Initialized = 1; +diff --git a/src/syslogd.h b/src/syslogd.h +index d74c0ed..0dce0ed 100644 +--- a/src/syslogd.h ++++ b/src/syslogd.h +@@ -226,8 +226,8 @@ + */ + struct peer { + TAILQ_ENTRY(peer) pe_link; +- const char *pe_name; +- const char *pe_serv; ++ char *pe_name; ++ char *pe_serv; + int pe_mark; + mode_t pe_mode; + int pe_sock[16]; +-- +2.43.0 + diff --git a/patches/sysklogd/2.5.2/0017-Fix-90-add-support-for-IPv6-addresses-in-listen-dire.patch b/patches/sysklogd/2.5.2/0017-Fix-90-add-support-for-IPv6-addresses-in-listen-dire.patch new file mode 100644 index 00000000..3d11cf87 --- /dev/null +++ b/patches/sysklogd/2.5.2/0017-Fix-90-add-support-for-IPv6-addresses-in-listen-dire.patch @@ -0,0 +1,47 @@ +From 691aea6cbe27134d4d4106bb0bca396aff2802f9 Mon Sep 17 00:00:00 2001 +From: Joachim Wiberg +Date: Tue, 27 Aug 2024 13:35:03 +0200 +Subject: [PATCH 17/17] Fix #90: add support for IPv6 addresses in listen + directive +Organization: Addiva Elektronik + +Signed-off-by: Joachim Wiberg +--- + src/syslogd.c | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +diff --git a/src/syslogd.c b/src/syslogd.c +index 9b8dc24..033be84 100644 +--- a/src/syslogd.c ++++ b/src/syslogd.c +@@ -3014,8 +3014,26 @@ static void init(void) + static void cflisten(char *ptr, void *arg) + { + char *peer = ptr; ++ char *p; ++ ++ while (*peer && isspace(*peer)) ++ ++peer; ++ ++ logit("cflisten[%s]\n", peer); ++ ++ p = peer; ++ if (*p == '[') { ++ p++; ++ ++ p = strchr(p, ']'); ++ if (!p) { ++ ERR("Invalid IPv6 address in listen '%s', missing ']'", peer); ++ return; ++ } ++ *p++ = 0; ++ } + +- ptr = strchr(peer, ':'); ++ ptr = strchr(p, ':'); + if (ptr) + *ptr++ = 0; + addpeer(&(struct peer) { +-- +2.43.0 +