From 69056bfb2c97272182c17ec790e5ffc9aa3d5d15 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 5 Aug 2025 07:56:19 +0200 Subject: [PATCH] board/common: fixes for unicode translation in log/pager commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - cli: add '-r' to log/pager/follow for "raw" control chars, including unicode - sysklogd: backport unicode fix for em-dash character (—) in slogan - sysklogd: drop old patches - sysklogd: run in 8-bit safe mode Signed-off-by: Joachim Wiberg --- board/common/rootfs/etc/bash.bashrc | 4 +- .../etc/finit.d/available/sysklogd.conf | 2 +- board/common/rootfs/usr/bin/pager | 3 +- ...edundant-initial-call-to-localtime_r.patch | 28 --- .../0002-fix-local-hostname-support.patch | 28 --- ...5-printsys-minor-code-simplification.patch | 31 ---- ...printlog_first-drop-superfluous-call.patch | 31 ---- ...ng-of-userspace-messages-in-dev-kmsg.patch | 118 ------------- ...-documentation-on-behavior-of-T-flag.patch | 99 ----------- ...7-Update-internal-timer-consistently.patch | 44 ----- ...-and-bump-version-for-upcoming-v2.7..patch | 61 ------- ...-update-ChangeLog-for-v2.7.1-release.patch | 47 ----- .../2.7.0/0010-Fix-various-typos.patch | 162 ------------------ ...sh-include-dots-in-name-and-verify-t.patch | 70 -------- ...end-tag-test-to-check-RFC3164-code-p.patch | 72 -------- ...-.-in-tag-names-regression-in-v2.7.1.patch | 40 ----- .../0014-Prepare-for-upcoming-v2.7.2.patch | 60 ------- ...lid-option-arguments-if-p-and-o-pars.patch | 57 ------ ...-and-bump-version-for-v2.7.2-release.patch | 47 ----- ...8-handling-with-8-flag-for-RFC5424-c.patch | 146 ++++++++++++++++ 20 files changed, 151 insertions(+), 999 deletions(-) delete mode 100644 patches/sysklogd/2.7.0/0001-Drop-redundant-initial-call-to-localtime_r.patch delete mode 100644 patches/sysklogd/2.7.0/0002-fix-local-hostname-support.patch delete mode 100644 patches/sysklogd/2.7.0/0003-Fix-95-printsys-minor-code-simplification.patch delete mode 100644 patches/sysklogd/2.7.0/0004-Fix-98-fprintlog_first-drop-superfluous-call.patch delete mode 100644 patches/sysklogd/2.7.0/0005-Fix-100-parsing-of-userspace-messages-in-dev-kmsg.patch delete mode 100644 patches/sysklogd/2.7.0/0006-Fix-93-update-documentation-on-behavior-of-T-flag.patch delete mode 100644 patches/sysklogd/2.7.0/0007-Update-internal-timer-consistently.patch delete mode 100644 patches/sysklogd/2.7.0/0008-Update-ChangeLog-and-bump-version-for-upcoming-v2.7..patch delete mode 100644 patches/sysklogd/2.7.0/0009-Bump-version-and-update-ChangeLog-for-v2.7.1-release.patch delete mode 100644 patches/sysklogd/2.7.0/0010-Fix-various-typos.patch delete mode 100644 patches/sysklogd/2.7.0/0011-test-update-tag.sh-include-dots-in-name-and-verify-t.patch delete mode 100644 patches/sysklogd/2.7.0/0012-test-further-extend-tag-test-to-check-RFC3164-code-p.patch delete mode 100644 patches/sysklogd/2.7.0/0013-Fix-102-allow-.-in-tag-names-regression-in-v2.7.1.patch delete mode 100644 patches/sysklogd/2.7.0/0014-Prepare-for-upcoming-v2.7.2.patch delete mode 100644 patches/sysklogd/2.7.0/0015-logger-show-invalid-option-arguments-if-p-and-o-pars.patch delete mode 100644 patches/sysklogd/2.7.0/0016-Update-ChangeLog-and-bump-version-for-v2.7.2-release.patch create mode 100644 patches/sysklogd/2.7.2/0001-syslogd-fix-UTF-8-handling-with-8-flag-for-RFC5424-c.patch diff --git a/board/common/rootfs/etc/bash.bashrc b/board/common/rootfs/etc/bash.bashrc index e4ea5d84..ce52f90e 100644 --- a/board/common/rootfs/etc/bash.bashrc +++ b/board/common/rootfs/etc/bash.bashrc @@ -35,14 +35,14 @@ log() { local fn="/var/log/syslog" [ -n "$1" ] && fn="/var/log/$1" - less +G "$fn" + less +G -r "$fn" } follow() { local fn="/var/log/syslog" [ -n "$1" ] && fn="/var/log/$1" - tail -F "$fn" + less +F -r "$fn" } _logfile_completions() diff --git a/board/common/rootfs/etc/finit.d/available/sysklogd.conf b/board/common/rootfs/etc/finit.d/available/sysklogd.conf index 6b7a5da1..a6bf7103 100644 --- a/board/common/rootfs/etc/finit.d/available/sysklogd.conf +++ b/board/common/rootfs/etc/finit.d/available/sysklogd.conf @@ -1,4 +1,4 @@ # Use as barrier for other system tasks and service that # rely on modules, firmware, and device nodes to be ready. service if:udevd nowarn env:-/etc/default/sysklogd \ - [S0123456789] syslogd -F $SYSLOGD_ARGS -- System log daemon + [S0123456789] syslogd -8 -F $SYSLOGD_ARGS -- System log daemon diff --git a/board/common/rootfs/usr/bin/pager b/board/common/rootfs/usr/bin/pager index cea4c3ec..ac5cd8ed 100755 --- a/board/common/rootfs/usr/bin/pager +++ b/board/common/rootfs/usr/bin/pager @@ -5,10 +5,11 @@ # -K :: exit immediately when an interrupt character (usually ^C) is typed # -R :: Almost raw control charachters, only ANSI color escape sequences and # OSC 8 hyperlink sequences are output. Allows veritcal scrolling +# -r :: Causes "raw" control characters to be displayed, including unicode. # -X :: No termcap initialization and deinitialization set to the terminal. # This is what leaves the contents of the output on screen. export LESS="-P %f (press h for help or q to quit)" export LANG=en_US.UTF-8 -less -RIKd -FX "$@" +less -rIKd -FX "$@" diff --git a/patches/sysklogd/2.7.0/0001-Drop-redundant-initial-call-to-localtime_r.patch b/patches/sysklogd/2.7.0/0001-Drop-redundant-initial-call-to-localtime_r.patch deleted file mode 100644 index 7ebea3f1..00000000 --- a/patches/sysklogd/2.7.0/0001-Drop-redundant-initial-call-to-localtime_r.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 8e230d3f2e1e33691998862e99ab4e13410527b9 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Wed, 8 Jan 2025 07:49:06 +0100 -Subject: [PATCH 01/16] Drop redundant initial call to localtime_r() -Organization: Wires - -Fixes #94 - -Signed-off-by: Joachim Wiberg ---- - src/syslogd.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/src/syslogd.c b/src/syslogd.c -index 17115fc..5ad4dbc 100644 ---- a/src/syslogd.c -+++ b/src/syslogd.c -@@ -1508,7 +1508,6 @@ void printsys(char *msg) - */ - if (KeepKernTime || !sys_seqno_init) { - now = boot_time + ustime / 1000000; -- localtime_r(&now, &buffer.timestamp.tm); - } else { - struct timeval tv; - --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0002-fix-local-hostname-support.patch b/patches/sysklogd/2.7.0/0002-fix-local-hostname-support.patch deleted file mode 100644 index 274d646a..00000000 --- a/patches/sysklogd/2.7.0/0002-fix-local-hostname-support.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 13c8071821ad27247061dbf4efe5a34505520bc1 Mon Sep 17 00:00:00 2001 -From: Patrick Oppenlander -Date: Thu, 23 Jan 2025 15:22:57 +1100 -Subject: [PATCH 02/16] fix local hostname '+@', '-@' support -Organization: Wires - -Signed-off-by: Patrick Oppenlander -Signed-off-by: Joachim Wiberg ---- - src/syslogd.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/syslogd.c b/src/syslogd.c -index 5ad4dbc..c07e143 100644 ---- a/src/syslogd.c -+++ b/src/syslogd.c -@@ -3895,7 +3895,7 @@ static int cfparse(FILE *fp, struct files *newf) - char *local = LocalHostName; - - while (i < sizeof(host) - 1 && *local) -- host[i++] = *local; -+ host[i++] = *local++; - p++; - } else if (!isprint(*p) || isblank(*p)) - break; --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0003-Fix-95-printsys-minor-code-simplification.patch b/patches/sysklogd/2.7.0/0003-Fix-95-printsys-minor-code-simplification.patch deleted file mode 100644 index e41becee..00000000 --- a/patches/sysklogd/2.7.0/0003-Fix-95-printsys-minor-code-simplification.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 979edb2515d24174fe9a3e2d6402d62172028c52 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sat, 1 Feb 2025 20:33:19 +0100 -Subject: [PATCH 03/16] Fix #95: printsys(), minor code simplification -Organization: Wires - -Signed-off-by: Joachim Wiberg ---- - src/syslogd.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/syslogd.c b/src/syslogd.c -index c07e143..f812d9e 100644 ---- a/src/syslogd.c -+++ b/src/syslogd.c -@@ -1511,11 +1511,11 @@ void printsys(char *msg) - } else { - struct timeval tv; - -- now = time(NULL); - if (gettimeofday(&tv, NULL) == -1) { - tv.tv_sec = time(NULL); - tv.tv_usec = 0; - } -+ now = tv.tv_sec; - ustime = tv.tv_usec; - } - --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0004-Fix-98-fprintlog_first-drop-superfluous-call.patch b/patches/sysklogd/2.7.0/0004-Fix-98-fprintlog_first-drop-superfluous-call.patch deleted file mode 100644 index e491ac15..00000000 --- a/patches/sysklogd/2.7.0/0004-Fix-98-fprintlog_first-drop-superfluous-call.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 360dfe4b6b17378990daef797a7e6a551c799b98 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sun, 2 Feb 2025 06:34:16 +0100 -Subject: [PATCH 04/16] Fix #98: fprintlog_first(), drop superfluous call -Organization: Wires - -The call to check_timestamp() is not needed (anymore) already called in -logmsg(), which is the only way of entering this function (today). - -Signed-off-by: Joachim Wiberg ---- - src/syslogd.c | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/src/syslogd.c b/src/syslogd.c -index f812d9e..6748cc6 100644 ---- a/src/syslogd.c -+++ b/src/syslogd.c -@@ -2424,9 +2424,6 @@ static void fprintlog_first(struct filed *f, struct buf_msg *buffer) - - logit("Called fprintlog_first(), "); - -- /* Messages generated by syslogd itself may not have a timestamp */ -- check_timestamp(buffer); -- - if (f->f_type != F_FORW_SUSP && f->f_type != F_FORW_UNKN) { - f->f_time = timer_now(); - f->f_prevcount = 0; --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0005-Fix-100-parsing-of-userspace-messages-in-dev-kmsg.patch b/patches/sysklogd/2.7.0/0005-Fix-100-parsing-of-userspace-messages-in-dev-kmsg.patch deleted file mode 100644 index c4121312..00000000 --- a/patches/sysklogd/2.7.0/0005-Fix-100-parsing-of-userspace-messages-in-dev-kmsg.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 472c3d6a24e43f8186ce069da267e9ae52c18699 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Thu, 27 Feb 2025 19:07:11 +0100 -Subject: [PATCH 05/16] Fix #100: parsing of userspace messages in /dev/kmsg -Organization: Wires - -Some applications that inject log messages to /dev/kmsg do not use a -space separating the APP_NAME (and optional PID), while some do. So we -need to support the following variants for the human readable payload, -as defined in [1]: - - 1. APP: MESG - 2. APP:MESG - 3. APP MESG - 4. APP[PID]: MESG - 5. APP[PID]:MESG - 6. APP[PID] MESG - -Prior to this change, 4 & 5 were treated the same, causing #100, and the -other alternatives were not supported at all. This patch drops the bad -local implementation in printsys() in favor of the generic parsemsg() -helper function for RFC3164 messages, which properly extracts both the -application name and PID if present. - -This helper's ': ' separator check is relaxed since some clients only -send ':' (no space) before the message. The RFC can be interpreted -either way, so we now allow either/or or no separator. - -[1]: https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg - -Signed-off-by: Joachim Wiberg ---- - src/syslogd.c | 55 +++++++++++++++++++++++++++------------------------ - 1 file changed, 29 insertions(+), 26 deletions(-) - -diff --git a/src/syslogd.c b/src/syslogd.c -index 6748cc6..b52af73 100644 ---- a/src/syslogd.c -+++ b/src/syslogd.c -@@ -1242,16 +1242,38 @@ parsemsg_rfc3164_app_name_procid(char **msg, char **app_name, char **procid) - procid_length = 0; - } - -- /* Separator. */ -- if (m[0] != ':' || m[1] != ' ') -- goto bad; -+ /* -+ * Relaxed separator check. This function is used both for -+ * incoming remote/local syslog messages, and the /dev/kmsg -+ * printsys() function. -+ * -+ * RFC3164 sec. 4.1.3 states that: "the conclusion of the TAG -+ * field has been seen to be the left square bracket character -+ * ('['), a colon character (':'), or a space character". This -+ * uncertainty continues in sec. 5.3: "a colon and a space -+ * character *usually* follow the TAG" (emphasis added). -+ * -+ * Hence, we should be prepared for any of: -+ * - APP: msg -+ * - APP:msg -+ * - APP msg -+ * - APP[PID]: msg -+ * - APP[PID]:msg -+ * - APP[PID] msg -+ */ -+ if (*m == ':') { -+ m++; -+ if (isblank(*m)) -+ m++; -+ } else if (isblank(*m)) -+ m++; - - /* Split strings from input. */ - app_name_begin[app_name_length] = '\0'; - if (procid_begin != 0) - procid_begin[procid_length] = '\0'; - -- *msg = m + 2; -+ *msg = m; - *app_name = app_name_begin; - *procid = procid_begin; - return; -@@ -1630,29 +1652,10 @@ void printsys(char *msg) - /* - * Check for user writing to /dev/kmsg before /dev/log - * is up. Syntax to write: APP_NAME[PROC_ID]:msg -+ * Kernel facility is 0, anything != 0 is userspace. - */ -- if (buffer.pri & LOG_FACMASK) { -- for (q = p; *q && !isspace(*q) && *q != '['; q++) -- ; -- -- if (*q == '[') { -- char *ptr = &q[1]; -- -- while (*ptr && isdigit(*ptr)) -- ptr++; -- -- if (ptr[0] == ']' && ptr[1] == ':') { -- *ptr++ = 0; -- *q++ = 0; -- -- buffer.app_name = p; -- buffer.proc_id = q; -- -- /* user log message cont. here */ -- p = &ptr[1]; -- } -- } -- } -+ if (buffer.pri & LOG_FACMASK) -+ parsemsg_rfc3164_app_name_procid(&p, &buffer.app_name, &buffer.proc_id); - - q = lp; - while (*p != '\0' && (c = *p++) != '\n' && q < &line[MAXLINE]) --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0006-Fix-93-update-documentation-on-behavior-of-T-flag.patch b/patches/sysklogd/2.7.0/0006-Fix-93-update-documentation-on-behavior-of-T-flag.patch deleted file mode 100644 index ea55e66a..00000000 --- a/patches/sysklogd/2.7.0/0006-Fix-93-update-documentation-on-behavior-of-T-flag.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 8cdf4b0c4b9914b8b7aa1c1c1d76dad0fa429115 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sat, 1 Mar 2025 09:23:01 +0100 -Subject: [PATCH 06/16] Fix #93: update documentation on behavior of -T flag -Organization: Wires - -Signed-off-by: Joachim Wiberg ---- - man/syslogd.8 | 17 ++++++++++------- - src/syslogd.c | 10 +++++----- - 2 files changed, 15 insertions(+), 12 deletions(-) - -diff --git a/man/syslogd.8 b/man/syslogd.8 -index f3e6ad2..7534529 100644 ---- a/man/syslogd.8 -+++ b/man/syslogd.8 -@@ -411,10 +411,13 @@ the command line option always wins, so it must be removed for - .Nm - to consider the .conf file option instead. - .It Fl T --Always use the local time and date for messages received from the network, --instead of the timestamp field supplied in the message by the remote host. --This is useful if some of the originating hosts cannot keep time properly --or are unable to generate a correct timestamp. -+Always use the local time and date for messages instead of the timestamp -+field in the log message. This applies to both messages received from a -+remote syslog server and locally originated. Useful if the originating -+hosts cannot keep time properly or are unable to generate a correct -+timestamp. See -+.Fl t -+for details on the timestamp of (local) kernel messages. - .It Fl t - Keep (trust) kernel timestamp. - .Pp -@@ -472,9 +475,9 @@ API included with the - .Nm sysklogd - project. - .Pp --The date and time are taken from the received message. If the format of --the timestamp field is incorrect, time obtained from the local host is --used instead. This can be overridden by the -+The date and time for a log message are by default read from the -+received message. If the format of the timestamp field is incorrect, -+the time of reception is used instead. See also the - .Fl T - flag. - .Sh SECURITY -diff --git a/src/syslogd.c b/src/syslogd.c -index b52af73..5a40732 100644 ---- a/src/syslogd.c -+++ b/src/syslogd.c -@@ -148,7 +148,7 @@ static int no_compress; /* don't compress messages (1=pipes, 2=all) */ - static int secure_opt; /* sink for others, log to remote, or only unix domain socks */ - static int secure_mode; /* same as above but from syslog.conf, only if cmdline unset */ - --static int RemoteAddDate; /* Always set the date on remote messages */ -+static int AlwaysAddDate; /* Always use our timestamp for log messages */ - static int RemoteHostname; /* Log remote hostname from the message */ - - static int KernLog = 1; /* Track kernel logs by default */ -@@ -458,7 +458,7 @@ int usage(int code) - " If specified twice, no socket at all will be opened, which also\n" - " disables support for logging to remote machines.\n" - " -t Keep kernel timestamp, even after initial ring buffer emptying\n" -- " -T Use local time and date for messages received from remote hosts\n" -+ " -T Use local time and date for log messages (both local and remote)\n" - " -? Show this help text\n" - " -v Show program version and exit\n" - "\n" -@@ -585,7 +585,7 @@ int main(int argc, char *argv[]) - break; - - case 'T': -- RemoteAddDate = 1; -+ AlwaysAddDate = 1; - break; - - case 't': /* keep/trust kernel timestamp always */ -@@ -1129,7 +1129,7 @@ parsemsg_rfc5424(const char *from, int pri, char *msg) - } - #undef PARSE_NUMBER - PARSE_CHAR("TIMESTAMP", ' '); -- if (!RemoteAddDate) -+ if (!AlwaysAddDate) - timestamp = ×tamp_remote; - } - -@@ -1311,7 +1311,7 @@ parsemsg_rfc3164(const char *from, int pri, char *msg) - - msg += RFC3164_DATELEN + 1; - -- if (!RemoteAddDate) { -+ if (!AlwaysAddDate) { - struct timeval tv; - time_t t_remote; - struct tm tm_now; --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0007-Update-internal-timer-consistently.patch b/patches/sysklogd/2.7.0/0007-Update-internal-timer-consistently.patch deleted file mode 100644 index 7bd236a9..00000000 --- a/patches/sysklogd/2.7.0/0007-Update-internal-timer-consistently.patch +++ /dev/null @@ -1,44 +0,0 @@ -From b5b4a4ecb893dd643fb25763fb9c6f6ca972725e Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sun, 2 Mar 2025 13:56:46 +0100 -Subject: [PATCH 07/16] Update internal timer consistently -Organization: Wires - -Timer is already updated by parsemsg() before calling logmsg(). For -consistency, add explicit update also to printsys() (kernel) and -flog() (internally originated) messages. - -Issue #70 - -Signed-off-by: Joachim Wiberg ---- - src/syslogd.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/src/syslogd.c b/src/syslogd.c -index 5a40732..1737f7c 100644 ---- a/src/syslogd.c -+++ b/src/syslogd.c -@@ -1467,6 +1467,9 @@ void printsys(char *msg) - char *lp, *p, *q; - int c; - -+ /* Update current time before logging */ -+ timer_update(); -+ - lp = line; - for (p = msg; *p != '\0';) { - memset(&buffer, 0, sizeof(buffer)); -@@ -2669,6 +2672,9 @@ void flog(int pri, char *fmt, ...) - char proc_id[10]; - va_list ap; - -+ /* Update current time before logging */ -+ timer_update(); -+ - va_start(ap, fmt); - (void)vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0008-Update-ChangeLog-and-bump-version-for-upcoming-v2.7..patch b/patches/sysklogd/2.7.0/0008-Update-ChangeLog-and-bump-version-for-upcoming-v2.7..patch deleted file mode 100644 index eddea4af..00000000 --- a/patches/sysklogd/2.7.0/0008-Update-ChangeLog-and-bump-version-for-upcoming-v2.7..patch +++ /dev/null @@ -1,61 +0,0 @@ -From d3362a104b414af2b352a15a6d1e92f823bdb9b6 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Sun, 2 Mar 2025 14:06:37 +0100 -Subject: [PATCH 08/16] Update ChangeLog and bump version for upcoming v2.7.1 - release -Organization: Wires - -Signed-off-by: Joachim Wiberg ---- - ChangeLog.md | 14 ++++++++++++++ - configure.ac | 2 +- - 2 files changed, 15 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog.md b/ChangeLog.md -index b96857f..aa3e793 100644 ---- a/ChangeLog.md -+++ b/ChangeLog.md -@@ -4,6 +4,19 @@ Change Log - All relevant changes to the project are documented in this file. - - -+[v2.7.1][UNRELEASED] - 2025-03-xx -+----------------------- -+ -+### Changes -+- Update `syslogd -T` documentation, it applies to messages originating -+ both locally and from both remote syslog servers, issue #93 -+ -+### Fixes -+- Fix #99: hostname filtering support, introduced in v2.7.0, broken -+- Fix #100: parsing of userspace messages in `/dev/kmsg` inserted an -+ extra space before the message payload -+ -+ - [v2.7.0][] - 2025-01-06 - ----------------------- - -@@ -667,6 +680,7 @@ and a replacement for `syslog.h` to enable new features in RFC5424. - - - [UNRELEASED]: https://github.com/troglobit/sysklogd/compare/v2.7.0...HEAD -+[v2.7.1]: https://github.com/troglobit/sysklogd/compare/v2.7.0...v2.7.1 - [v2.7.0]: https://github.com/troglobit/sysklogd/compare/v2.6.2...v2.7.0 - [v2.6.2]: https://github.com/troglobit/sysklogd/compare/v2.6.1...v2.6.2 - [v2.6.1]: https://github.com/troglobit/sysklogd/compare/v2.6.0...v2.6.1 -diff --git a/configure.ac b/configure.ac -index f387800..64de416 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -25,7 +25,7 @@ - # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - # SUCH DAMAGE. - --AC_INIT([sysklogd], [2.7.0], -+AC_INIT([sysklogd], [2.7.1-rc1], - [https://github.com/troglobit/sysklogd/issues],, - [https://github.com/troglobit/sysklogd]) - AC_CONFIG_AUX_DIR(aux) --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0009-Bump-version-and-update-ChangeLog-for-v2.7.1-release.patch b/patches/sysklogd/2.7.0/0009-Bump-version-and-update-ChangeLog-for-v2.7.1-release.patch deleted file mode 100644 index ad46ff6a..00000000 --- a/patches/sysklogd/2.7.0/0009-Bump-version-and-update-ChangeLog-for-v2.7.1-release.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 5552a3ea0d025573a5e212d62ee3e04bd376c7c4 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Mon, 3 Mar 2025 03:17:39 +0100 -Subject: [PATCH 09/16] Bump version and update ChangeLog for v2.7.1 release -Organization: Wires - -Signed-off-by: Joachim Wiberg ---- - ChangeLog.md | 4 ++-- - configure.ac | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/ChangeLog.md b/ChangeLog.md -index aa3e793..12829c0 100644 ---- a/ChangeLog.md -+++ b/ChangeLog.md -@@ -4,12 +4,12 @@ Change Log - All relevant changes to the project are documented in this file. - - --[v2.7.1][UNRELEASED] - 2025-03-xx -+[v2.7.1][] - 2025-03-03 - ----------------------- - - ### Changes - - Update `syslogd -T` documentation, it applies to messages originating -- both locally and from both remote syslog servers, issue #93 -+ both locally and from remote syslog servers, issue #93 - - ### Fixes - - Fix #99: hostname filtering support, introduced in v2.7.0, broken -diff --git a/configure.ac b/configure.ac -index 64de416..a2cf9be 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -25,7 +25,7 @@ - # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - # SUCH DAMAGE. - --AC_INIT([sysklogd], [2.7.1-rc1], -+AC_INIT([sysklogd], [2.7.1], - [https://github.com/troglobit/sysklogd/issues],, - [https://github.com/troglobit/sysklogd]) - AC_CONFIG_AUX_DIR(aux) --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0010-Fix-various-typos.patch b/patches/sysklogd/2.7.0/0010-Fix-various-typos.patch deleted file mode 100644 index e962942f..00000000 --- a/patches/sysklogd/2.7.0/0010-Fix-various-typos.patch +++ /dev/null @@ -1,162 +0,0 @@ -From 64cd26232e598f902cf93b540152df5f7d8991e8 Mon Sep 17 00:00:00 2001 -From: Luz Paz -Date: Mon, 3 Mar 2025 07:16:35 -0500 -Subject: [PATCH 10/16] Fix various typos Fixes user-facing and non-user-facing - typos Found via `codespell -q 3 -L bootup,clen,nd,servent,siz,tast,unx` -Organization: Wires - -Signed-off-by: Joachim Wiberg ---- - ChangeLog.md | 2 +- - README.md | 2 +- - man/syslog.conf.5 | 2 +- - src/logger.c | 2 +- - src/syslog.h | 2 +- - src/syslogd.c | 4 ++-- - src/syslogd.h | 2 +- - syslog.conf | 4 ++-- - test/listen.sh | 4 ++-- - 9 files changed, 12 insertions(+), 12 deletions(-) - -diff --git a/ChangeLog.md b/ChangeLog.md -index 12829c0..da44e01 100644 ---- a/ChangeLog.md -+++ b/ChangeLog.md -@@ -508,7 +508,7 @@ and a replacement for `syslog.h` to enable new features in RFC5424. - - New `syslogp()` API from NetBSD, for applications wanting to use - RFC5424 features like MsgID or structured data - - Many *incompatible changes* to command line options in `syslogd` and -- `klogd` for compatiblity with FreeBSD and NetBSD syslogd. Examples: -+ `klogd` for compatibility with FreeBSD and NetBSD syslogd. Examples: - - In syslogd: `-b` and `-c` have been replaced with `-r` for global - log rotation, `-a` has been replaced with the new `-p` support. The - `-r` flag and `-s HOST` has also been dropped in favor of the BSD -diff --git a/README.md b/README.md -index eff6b03..12ce92c 100644 ---- a/README.md -+++ b/README.md -@@ -63,7 +63,7 @@ Main differences from the original sysklogd package are: - - - The separate `klogd` daemon is no longer part of the sysklogd project, - syslogd now natively supports logging kernel messages as well --- *Major* command line changes to `syslogd`, for compatibilty with *BSD -+- *Major* command line changes to `syslogd`, for compatibility with *BSD - - Supports `include /etc/syslog.d/*.conf` directive, see example .conf - - Built-in log-rotation support, with compression by default, useful for - embedded systems. No need for cron and/or a separate log rotate daemon -diff --git a/man/syslog.conf.5 b/man/syslog.conf.5 -index f7d9ea1..64a7260 100644 ---- a/man/syslog.conf.5 -+++ b/man/syslog.conf.5 -@@ -704,7 +704,7 @@ This example shows one combination of program and hostname filters. - !-ppp - *.* /var/log/syslog - --# Local pppd messages of severity info, or higer, go to its own log file -+# Local pppd messages of severity info, or higher, go to its own log file - !+ppp - *.info /var/log/ppp.log - -diff --git a/src/logger.c b/src/logger.c -index ffdb9e1..8fcb42a 100644 ---- a/src/logger.c -+++ b/src/logger.c -@@ -286,7 +286,7 @@ static int usage(int code) - " -h HOST Send (UDP) message to this remote syslog server (IP or DNS name)\n" - " -H NAME Use NAME instead of system hostname in message header\n" - " -i Log process ID of the logger process with each line (LOG_PID)\n" -- " -I PID Log process ID using PID, recommed using PID $$ for shell scripts\n" -+ " -I PID Log process ID using PID, recommend using PID $$ for shell scripts\n" - #ifdef __linux__ - " -k Log to kernel /dev/kmsg if /dev/log doesn't exist yet\n" - #endif -diff --git a/src/syslog.h b/src/syslog.h -index 9c33967..4f35ad0 100644 ---- a/src/syslog.h -+++ b/src/syslog.h -@@ -191,7 +191,7 @@ CODE facilitynames[] = { - #define LOG_NDELAY 0x008 /* don't delay open */ - #define LOG_NOWAIT 0x010 /* don't wait for console forks: DEPRECATED */ - #define LOG_PERROR 0x020 /* log to stderr as well */ --#define LOG_PTRIM 0x040 /* trim anything syslog addded when writing to stderr */ -+#define LOG_PTRIM 0x040 /* trim anything syslog added when writing to stderr */ - #define LOG_NLOG 0x080 /* don't write to the system log */ - #define LOG_STDOUT 0x100 /* like nlog, for debugging syslogp() API */ - #define LOG_RFC3164 0x200 /* Log to remote/ipc socket in old BSD format */ -diff --git a/src/syslogd.c b/src/syslogd.c -index 1737f7c..9128e7f 100644 ---- a/src/syslogd.c -+++ b/src/syslogd.c -@@ -177,7 +177,7 @@ static TAILQ_HEAD(notifiers, notifier) nothead = TAILQ_HEAD_INITIALIZER(nothead) - static TAILQ_HEAD(peers, peer) pqueue = TAILQ_HEAD_INITIALIZER(pqueue); - - /* -- * List fo peers allowed to log to us. -+ * List of peers allowed to log to us. - */ - static SIMPLEQ_HEAD(allowed, allowedpeer) aphead = SIMPLEQ_HEAD_INITIALIZER(aphead); - -@@ -4456,7 +4456,7 @@ static void notifier_free_all(void) - } - - /* -- * The following function is resposible for handling a SIGHUP signal. Since -+ * The following function is responsible for handling a SIGHUP signal. Since - * we are now doing mallocs/free as part of init we had better not being - * doing this during a signal handler. Instead this function simply sets - * a flag variable which will tell the main loop to go through a restart. -diff --git a/src/syslogd.h b/src/syslogd.h -index ff97a0a..511e3e8 100644 ---- a/src/syslogd.h -+++ b/src/syslogd.h -@@ -224,7 +224,7 @@ - #define F_PIPE 9 /* named pipe */ - - /* -- * Stuct to hold property-based filters -+ * Struct to hold property-based filters - */ - struct prop_filter { - uint8_t prop_type; -diff --git a/syslog.conf b/syslog.conf -index 581fc32..3426c25 100644 ---- a/syslog.conf -+++ b/syslog.conf -@@ -44,7 +44,7 @@ mail.err /var/log/mail.err - - # - # Store all critical events, except kernel logs, in critical RFC5424 format. --# Overide global log rotation settings, rotate every 10MiB, keep 5 old logs, -+# Override global log rotation settings, rotate every 10MiB, keep 5 old logs, - # - #*.=crit;kern.none /var/log/critical ;rotate=10M:5,RFC5424 - -@@ -68,7 +68,7 @@ mail.err /var/log/mail.err - # Secure mode, same as -s, none(0), on(1), full(2). When enabled - # only logging to remote syslog server possible, with full secure - # mode, not even that is possible. We default to prevent syslogd --# from opening UDP/514 and receving messages from other systems. -+# from opening UDP/514 and receiving messages from other systems. - # - secure_mode 1 - -diff --git a/test/listen.sh b/test/listen.sh -index 1b706e8..7665261 100755 ---- a/test/listen.sh -+++ b/test/listen.sh -@@ -99,10 +99,10 @@ run_step "Verify listen off - no remote no ports" verify_secure_daem - run_step "Verify listen off - only send to remote, no ports" verify_safe_daemon - run_step "Verify listen on, default" verify_default_daemon - --run_step "Verfiy listen on 127.0.0.1:510" verify_local_daemon -+run_step "Verify listen on 127.0.0.1:510" verify_local_daemon - run_step "Verify port 514 is closed" check_not_open 514 - --run_step "Verfiy listen on 10.0.0.1:512" verify_bind -+run_step "Verify listen on 10.0.0.1:512" verify_bind - run_step "Verify port 510 is closed" check_not_open 510 - - run_step "Verify delayed bind to new address 10.0.0.2:513" verify_delayed_bind --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0011-test-update-tag.sh-include-dots-in-name-and-verify-t.patch b/patches/sysklogd/2.7.0/0011-test-update-tag.sh-include-dots-in-name-and-verify-t.patch deleted file mode 100644 index 10f73ee0..00000000 --- a/patches/sysklogd/2.7.0/0011-test-update-tag.sh-include-dots-in-name-and-verify-t.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 2fbac9e54b60e813a5ecfb4ff4177b6351bfbffd Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Tue, 18 Mar 2025 06:32:27 +0100 -Subject: [PATCH 11/16] test: update tag.sh, include dots in name and verify - tag in logfile -Organization: Wires - -Issue #102 - -Signed-off-by: Joachim Wiberg ---- - test/tag.sh | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/test/tag.sh b/test/tag.sh -index 3e1c598..bfc409a 100755 ---- a/test/tag.sh -+++ b/test/tag.sh -@@ -1,16 +1,20 @@ - #!/bin/sh - # Verify log filtering based on ident/tag. -+#DEBUG=true - . "${srcdir:-.}/lib.sh" - - TG1=pimd - TG2=mrouted -+TG3=in.tftpd - MSG="Multicast, a perfect weapon for an imperfect time." - UNX="In UNIX we trust" -+DOT="We bring 512 byte block gifts" - - LOGDIR="$DIR/log" - SYSLOG="${LOGDIR}/syslog" - TG1LOG="${LOGDIR}/$TG1.log" - TG2LOG="${LOGDIR}/$TG2.log" -+TG3LOG="${LOGDIR}/$TG3.log" - - setup_syslogd() - { -@@ -22,6 +26,8 @@ setup_syslogd() - *.* $TG1LOG - #!$TG2 - *.* $TG2LOG -+ #!$TG3 -+ *.* $TG3LOG - EOF - setup -m0 - } -@@ -32,8 +38,8 @@ verify_tag() - log="$1"; shift - msg="$*" - -- logger -t "$tag" "$msg" -- grep "$msg" "$log" -+ logger -ip user.debug -t "$tag" "$msg" -+ grep "$msg" "$log" |grep "$tag" - } - - verify_log() -@@ -52,6 +58,7 @@ verify_not() - run_step "Set up property based filtering syslogd" setup_syslogd - run_step "Verify basic tag based filtering (1)" verify_tag "$TG1" "$TG1LOG" "$MSG" - run_step "Verify basic tag based filtering (2)" verify_tag "$TG2" "$TG2LOG" "$MSG" -+run_step "Verify basic tag based filtering (3)" verify_tag "$TG3" "$TG3LOG" "$DOT" - run_step "Verify not in syslog" verify_not "$SYSLOG" "$MSG" - - run_step "Verify unfiltered tag logging" verify_tag "foo" "$SYSLOG" "$UNX" --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0012-test-further-extend-tag-test-to-check-RFC3164-code-p.patch b/patches/sysklogd/2.7.0/0012-test-further-extend-tag-test-to-check-RFC3164-code-p.patch deleted file mode 100644 index 1a630a1e..00000000 --- a/patches/sysklogd/2.7.0/0012-test-further-extend-tag-test-to-check-RFC3164-code-p.patch +++ /dev/null @@ -1,72 +0,0 @@ -From ff09758a63f100d5e611d28b1f219ea10f2ca996 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Wed, 19 Mar 2025 06:08:45 +0100 -Subject: [PATCH 12/16] test: further extend tag test to check RFC3164 code - path as well -Organization: Wires - -Reproduces issue #102 - -Signed-off-by: Joachim Wiberg ---- - test/tag.sh | 33 +++++++++++++++++++++++++++++---- - 1 file changed, 29 insertions(+), 4 deletions(-) - -diff --git a/test/tag.sh b/test/tag.sh -index bfc409a..53aa745 100755 ---- a/test/tag.sh -+++ b/test/tag.sh -@@ -1,6 +1,11 @@ - #!/bin/sh --# Verify log filtering based on ident/tag. --#DEBUG=true -+# Verify log filtering based on ident/tag for both RFC3154 (BSD) -+# and RFC5424 formatted log messages sent to syslogd. A logged -+# message can also contain a [PID], so the combinations of various -+# tags + pid are also covered. -+# -+# Regression test for issue #102. -+# - . "${srcdir:-.}/lib.sh" - - TG1=pimd -@@ -32,14 +37,34 @@ setup_syslogd() - setup -m0 - } - -+# Verify both RFC3164 (BSD) log format and RFC5424, because -+# they have different format parsers in syslogd. Generates -+# three additional variants of the given log message: rev, -+# rot13, and alphabetically sorted. - verify_tag() - { - tag="$1"; shift - log="$1"; shift - msg="$*" -+ rev=$(echo "$msg" | rev) -+ rot=$(echo "$msg" | tr 'a-zA-Z' 'n-za-mN-ZA-M') -+ bin=$(echo "$msg" | sed 's/./&\n/g' | sort | tr -d '\n') - -- logger -ip user.debug -t "$tag" "$msg" -- grep "$msg" "$log" |grep "$tag" -+ # BSD log format (with -b) -+ logger -b -ip user.debug -t "$tag" "$msg" -+ verify_log "$log" "$msg" | grep "$tag" || return 1 -+ -+ # RFC5424 (default) -+ logger -ip user.debug -t "$tag" "$rev" -+ verify_log "$log" "$rev" | grep "$tag" || return 1 -+ -+ # BSD without -p flag -+ logger -b -i -t "$tag" "$rot" -+ verify_log "$log" "$rot" | grep "$tag" || return 1 -+ -+ # RFC5424 without -p flag -+ logger -i -t "$tag" "$bin" -+ verify_log "$log" "$bin" | grep "$tag" || return 1 - } - - verify_log() --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0013-Fix-102-allow-.-in-tag-names-regression-in-v2.7.1.patch b/patches/sysklogd/2.7.0/0013-Fix-102-allow-.-in-tag-names-regression-in-v2.7.1.patch deleted file mode 100644 index c8bd159e..00000000 --- a/patches/sysklogd/2.7.0/0013-Fix-102-allow-.-in-tag-names-regression-in-v2.7.1.patch +++ /dev/null @@ -1,40 +0,0 @@ -From c0622119d6baf45dcaef01897f6c686f2eb92ee4 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Wed, 19 Mar 2025 06:35:39 +0100 -Subject: [PATCH 13/16] Fix #102: allow '.' in tag names, regression in v2.7.1 -Organization: Wires - -RFC3164 specifies; "The TAG is a string of ABNF alphanumeric characters - that MUST NOT exceed 32 characters. Any non-alphanumeric character - will terminate the TAG field and will be assumed to be the starting - character of the CONTENT field." - -Strictly speaking, ABNF (Augmented Backus-Naur Form) only includes the -alphanumeric characters, meaning just be letters and digits. - -However, in real-life scenarios, and per previous behavior, we should -definitely allow '.' as well. The existing argument to `strspn()` is -from FreeBSD, which for some reason do *not* allow '.', but they do -also allow '_-/' ... '/' seems like the real outlier here. - -Signed-off-by: Joachim Wiberg ---- - src/syslogd.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/syslogd.c b/src/syslogd.c -index 9128e7f..07abdf9 100644 ---- a/src/syslogd.c -+++ b/src/syslogd.c -@@ -1223,7 +1223,7 @@ parsemsg_rfc3164_app_name_procid(char **msg, char **app_name, char **procid) - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789" -- "_-/"); -+ "._-/"); - if (app_name_length == 0) - goto bad; - m += app_name_length; --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0014-Prepare-for-upcoming-v2.7.2.patch b/patches/sysklogd/2.7.0/0014-Prepare-for-upcoming-v2.7.2.patch deleted file mode 100644 index aa852dcb..00000000 --- a/patches/sysklogd/2.7.0/0014-Prepare-for-upcoming-v2.7.2.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 93f9cd74856be4b9a77c72b8e4c55a49c32ce26e Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Mon, 24 Mar 2025 06:01:46 +0100 -Subject: [PATCH 14/16] Prepare for upcoming v2.7.2 -Organization: Wires - -Signed-off-by: Joachim Wiberg ---- - ChangeLog.md | 14 +++++++++++++- - configure.ac | 2 +- - 2 files changed, 14 insertions(+), 2 deletions(-) - -diff --git a/ChangeLog.md b/ChangeLog.md -index da44e01..140cfc4 100644 ---- a/ChangeLog.md -+++ b/ChangeLog.md -@@ -4,6 +4,17 @@ Change Log - All relevant changes to the project are documented in this file. - - -+[v2.7.2][UNRELEASED] -+----------------------- -+ -+### Changes -+- Increased code coverage testing of tag parser -+ -+### Fixes -+- Fix #102: allow `.` in tag names, regression in v2.7.1 -+- Fix various typos in documentation, by Luz Paz -+ -+ - [v2.7.1][] - 2025-03-03 - ----------------------- - -@@ -679,7 +690,8 @@ and a replacement for `syslog.h` to enable new features in RFC5424. - - Several bugfixes and improvements, please refer to the .c files - - --[UNRELEASED]: https://github.com/troglobit/sysklogd/compare/v2.7.0...HEAD -+[UNRELEASED]: https://github.com/troglobit/sysklogd/compare/v2.7.1...HEAD -+[v2.7.2]: https://github.com/troglobit/sysklogd/compare/v2.7.1...v2.7.2 - [v2.7.1]: https://github.com/troglobit/sysklogd/compare/v2.7.0...v2.7.1 - [v2.7.0]: https://github.com/troglobit/sysklogd/compare/v2.6.2...v2.7.0 - [v2.6.2]: https://github.com/troglobit/sysklogd/compare/v2.6.1...v2.6.2 -diff --git a/configure.ac b/configure.ac -index a2cf9be..13dadfa 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -25,7 +25,7 @@ - # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - # SUCH DAMAGE. - --AC_INIT([sysklogd], [2.7.1], -+AC_INIT([sysklogd], [2.7.2-beta1], - [https://github.com/troglobit/sysklogd/issues],, - [https://github.com/troglobit/sysklogd]) - AC_CONFIG_AUX_DIR(aux) --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0015-logger-show-invalid-option-arguments-if-p-and-o-pars.patch b/patches/sysklogd/2.7.0/0015-logger-show-invalid-option-arguments-if-p-and-o-pars.patch deleted file mode 100644 index 3976a4dc..00000000 --- a/patches/sysklogd/2.7.0/0015-logger-show-invalid-option-arguments-if-p-and-o-pars.patch +++ /dev/null @@ -1,57 +0,0 @@ -From debc8c337b3e7d8c76701991a4566714b78c1846 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Mon, 31 Mar 2025 13:22:47 +0200 -Subject: [PATCH 15/16] logger: show invalid option arguments if -p and -o - parsing fail -Organization: Wires - -Instead of just showing the usage instructions, include information -about the option and its argument failing. Useful when debugging -faulty calls to the logger program deep in an operating system. - -Signed-off-by: Joachim Wiberg ---- - src/logger.c | 14 +++++++++++--- - 1 file changed, 11 insertions(+), 3 deletions(-) - -diff --git a/src/logger.c b/src/logger.c -index 8fcb42a..5bf263f 100644 ---- a/src/logger.c -+++ b/src/logger.c -@@ -393,13 +393,17 @@ int main(int argc, char *argv[]) - break; - - case 'o': -- if (parse_opts(optarg, &iface, &ttl)) -+ if (parse_opts(optarg, &iface, &ttl)) { -+ printf("Invalid option argument '-%c %s'\n", c, optarg); - return usage(1); -+ } - break; - - case 'p': -- if (parse_prio(optarg, &facility, &severity)) -+ if (parse_prio(optarg, &facility, &severity)) { -+ printf("Invalid option argument '-%c %s'\n", c, optarg); - return usage(1); -+ } - break; - - case 'P': -@@ -428,8 +432,12 @@ int main(int argc, char *argv[]) - printf("%s\n", version_info); - return 0; - -- default: -+ case '?': - return usage(0); -+ -+ default: -+ printf("Unsupported option '-%c'\n", c); -+ return usage(1); - } - } - --- -2.43.0 - diff --git a/patches/sysklogd/2.7.0/0016-Update-ChangeLog-and-bump-version-for-v2.7.2-release.patch b/patches/sysklogd/2.7.0/0016-Update-ChangeLog-and-bump-version-for-v2.7.2-release.patch deleted file mode 100644 index b1424ccc..00000000 --- a/patches/sysklogd/2.7.0/0016-Update-ChangeLog-and-bump-version-for-v2.7.2-release.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 5fb314cb9060afa3bd4eed2f0be3200f02f729e9 Mon Sep 17 00:00:00 2001 -From: Joachim Wiberg -Date: Mon, 31 Mar 2025 13:26:13 +0200 -Subject: [PATCH 16/16] Update ChangeLog and bump version for v2.7.2 release -Organization: Wires - -Signed-off-by: Joachim Wiberg ---- - ChangeLog.md | 4 +++- - configure.ac | 2 +- - 2 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/ChangeLog.md b/ChangeLog.md -index 140cfc4..8d8bb43 100644 ---- a/ChangeLog.md -+++ b/ChangeLog.md -@@ -4,11 +4,13 @@ Change Log - All relevant changes to the project are documented in this file. - - --[v2.7.2][UNRELEASED] -+[v2.7.2][] - 2025-03-31 - ----------------------- - - ### Changes - - Increased code coverage testing of tag parser -+- Improved error handling in `logger` when invalid arguments to -+ `-p` and `-o` are encountered - - ### Fixes - - Fix #102: allow `.` in tag names, regression in v2.7.1 -diff --git a/configure.ac b/configure.ac -index 13dadfa..fe79595 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -25,7 +25,7 @@ - # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - # SUCH DAMAGE. - --AC_INIT([sysklogd], [2.7.2-beta1], -+AC_INIT([sysklogd], [2.7.2], - [https://github.com/troglobit/sysklogd/issues],, - [https://github.com/troglobit/sysklogd]) - AC_CONFIG_AUX_DIR(aux) --- -2.43.0 - diff --git a/patches/sysklogd/2.7.2/0001-syslogd-fix-UTF-8-handling-with-8-flag-for-RFC5424-c.patch b/patches/sysklogd/2.7.2/0001-syslogd-fix-UTF-8-handling-with-8-flag-for-RFC5424-c.patch new file mode 100644 index 00000000..25968b5f --- /dev/null +++ b/patches/sysklogd/2.7.2/0001-syslogd-fix-UTF-8-handling-with-8-flag-for-RFC5424-c.patch @@ -0,0 +1,146 @@ +From 31dfe0d16461d2852f3fc56cb82aed3a23db022f Mon Sep 17 00:00:00 2001 +From: Joachim Wiberg +Date: Thu, 25 Sep 2025 16:48:31 +0200 +Subject: [PATCH] syslogd: fix UTF-8 handling with -8 flag, for RFC5424 + compliance +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Organization: Wires + +The -8 flag was designed to preserve 8-bit data but failed with multi-byte +UTF-8 sequences like em-dash (—). The parsemsg_remove_unsafe_characters() +function processed UTF-8 byte-by-byte, corrupting sequences even with -8. + +Changes: +- Add UTF-8 sequence detection and validation functions +- Preserve complete valid UTF-8 sequences when -8 flag is used +- Support UTF-8 BOM per RFC5424 requirements +- Maintain backward compatibility and security filtering + +Fixes #105 + +Signed-off-by: Joachim Wiberg +--- + src/syslogd.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 93 insertions(+), 2 deletions(-) + +diff --git a/src/syslogd.c b/src/syslogd.c +index 07abdf9..fa82d98 100644 +--- a/src/syslogd.c ++++ b/src/syslogd.c +@@ -997,18 +997,109 @@ void untty(void) + #endif + } + ++/* ++ * Returns the length of a UTF-8 sequence starting at *in, or 0 if invalid. ++ * Does not validate the entire sequence, just checks the start byte. ++ */ ++static size_t ++utf8_len(const unsigned char *in) ++{ ++ unsigned char c = *in; ++ ++ if ((c & 0x80) == 0x00) return 1; /* ASCII: 0xxxxxxx */ ++ if ((c & 0xE0) == 0xC0) return 2; /* 110xxxxx */ ++ if ((c & 0xF0) == 0xE0) return 3; /* 1110xxxx */ ++ if ((c & 0xF8) == 0xF0) return 4; /* 11110xxx */ ++ ++ return 0; /* Invalid start byte */ ++} ++ ++/* ++ * Validates a complete UTF-8 sequence of given length. ++ * Returns 1 if valid, 0 if invalid. ++ */ ++static int ++utf8_valid(const unsigned char *in, size_t len) ++{ ++ size_t i; ++ ++ switch (len) { ++ case 1: ++ if ((*in & 0x80) != 0x00) ++ return 0; ++ break; ++ case 2: ++ if ((*in & 0xE0) != 0xC0) ++ return 0; ++ if (*in < 0xC2) ++ return 0; /* Overlong encoding */ ++ break; ++ case 3: ++ if ((*in & 0xF0) != 0xE0) ++ return 0; ++ break; ++ case 4: ++ if ((*in & 0xF8) != 0xF0) ++ return 0; ++ if (*in > 0xF4) ++ return 0; /* Beyond Unicode range */ ++ break; ++ default: ++ return 0; ++ } ++ ++ /* Check continuation bytes */ ++ for (i = 1; i < len; i++) { ++ if ((in[i] & 0xC0) != 0x80) ++ return 0; ++ } ++ ++ /* Check for overlong encodings and surrogates */ ++ if (len == 3 && *in == 0xE0 && (in[1] & 0xE0) == 0x80) return 0; ++ if (len == 4 && *in == 0xF0 && (in[1] & 0xF0) == 0x80) return 0; ++ if (len == 3 && *in == 0xED && (in[1] & 0xE0) == 0xA0) return 0; /* Surrogates */ ++ ++ return 1; ++} ++ + /* + * Removes characters from log messages that are unsafe to display. +- * TODO: Permit UTF-8 strings that include a BOM per RFC 5424? ++ * Preserves valid UTF-8 sequences, including BOM, with -8 flag. + */ + static void + parsemsg_remove_unsafe_characters(const char *in, char *out, size_t outlen) + { ++ const unsigned char *p = (const unsigned char *)in; + char *q; + int c; + + q = out; +- while ((c = (unsigned char)*in++) != '\0' && q < out + outlen - 4) { ++ while (*p && q < out + outlen - 4) { ++ /* When -8 flag is used, try UTF-8 processing first */ ++ if (!mask_C1 && (*p & 0x80)) { ++ size_t len = utf8_len(p); ++ ++ /* Check if we have a complete UTF-8 sequence */ ++ if (len > 0 && q + len < out + outlen) { ++ size_t i = 0; ++ ++ /* Ensure we have enough input bytes */ ++ while (i < len && p[i] != '\0') ++ i++; ++ ++ if (i == len && utf8_valid(p, len)) { ++ /* Copy the entire valid UTF-8 sequence */ ++ for (i = 0; i < len; i++) ++ *q++ = *p++; ++ continue; ++ } ++ } ++ /* Fall through to byte-by-byte processing for invalid UTF-8 */ ++ } ++ ++ /* Byte-by-byte processing */ ++ c = *p++; ++ + if (mask_C1 && (c & 0x80) && c < 0xA0) { + c &= 0x7F; + *q++ = 'M'; +-- +2.43.0 +