From b35f7581e09abde508b79793f0c4e2d92dca7fcf Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Mon, 23 Jun 2014 17:47:10 +0200 Subject: [PATCH] Cherry-pick upstream fix to properly handle multiline syslog messages Closes: #746351 --- debian/changelog | 2 + ...nal-handle-multiline-syslog-messages.patch | 75 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 78 insertions(+) create mode 100644 debian/patches/journal-handle-multiline-syslog-messages.patch diff --git a/debian/changelog b/debian/changelog index cc896fb24..ca5812f58 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ systemd (204-11) UNRELEASED; urgency=medium [ Michael Biebl ] * Make no-patch-numbers the default for gbp-pq. + * Cherry-pick upstream fix to properly handle multiline syslog messages. + (Closes: #746351) [ Michael Stapelberg ] * Clarify that “systemd” does not influence init whereas “systemd-sysv” does diff --git a/debian/patches/journal-handle-multiline-syslog-messages.patch b/debian/patches/journal-handle-multiline-syslog-messages.patch new file mode 100644 index 000000000..36628581a --- /dev/null +++ b/debian/patches/journal-handle-multiline-syslog-messages.patch @@ -0,0 +1,75 @@ +From: Harald Hoyer +Date: Thu, 1 Aug 2013 12:14:02 +0200 +Subject: journal: handle multiline syslog messages +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Since the journal can handle multiple lines just well natively, +and rsyslog can be configured to handle them as well, there is no need +to truncate messages from syslog() after the first newline. + +Reproducer: + +1. Add following four lines to /etc/rsyslog.conf + + ---------- + $EscapeControlCharactersOnReceive off + $ActionFileDefaultTemplate RSYSLOG_SysklogdFileFormat + $SpaceLFOnReceive on + $DropTrailingLFOnReception off + ---------- + +3. Restart rsyslog + # service rsyslog restart + +4. Compile and run the following program + + ---------- + #include + #include + + int main() + { + syslog(LOG_INFO, "aaa%caaa", '\n'); + return 0; + } + ---------- + +Actual results: +Below message appears in /var/log/messages. + + ---------- +   Sep 7 19:19:39 localhost test2: aaa + ---------- + +Expected results: +Below message, which worked prior to systemd-journald +appears in /var/log/messages. + + ---------- +   Sep 7 19:19:39 localhost test2: aaa aaa + +https://bugzilla.redhat.com/show_bug.cgi?id=855313 +--- + src/journal/journald-server.c | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c +index 01f23ce..5c607b6 100644 +--- a/src/journal/journald-server.c ++++ b/src/journal/journald-server.c +@@ -1142,12 +1142,7 @@ int process_event(Server *s, struct epoll_event *ev) { + char *e; + + if (n > 0 && n_fds == 0) { +- e = memchr(s->buffer, '\n', n); +- if (e) +- *e = 0; +- else +- s->buffer[n] = 0; +- ++ s->buffer[n] = 0; + server_process_syslog_message(s, strstrip(s->buffer), ucred, tv, label, label_len); + } else if (n_fds > 0) + log_warning("Got file descriptors via syslog socket. Ignoring."); diff --git a/debian/patches/series b/debian/patches/series index 70df6c875..451a74091 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -55,3 +55,4 @@ Add-targets-for-compatibility-with-Debian-insserv-sy.patch more-cd-aliases.patch rules-drivers-always-call-kmod-even-when-a-driver-is.patch Advertise-hibernation-only-if-there-s-enough-free-sw.patch +journal-handle-multiline-syslog-messages.patch