Re: [systemd-devel] [PATCH] journal: handle multiline syslog messages
On 08/05/2013 02:12 PM, Lennart Poettering wrote: On Thu, 01.08.13 12:22, har...@redhat.com (har...@redhat.com) wrote: From: Harald Hoyer har...@redhat.com 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. So, hmm. I am a bit concerned about this as syslog-over-stream uses NL as a record separator. syslog-over-dgram doesn't need it as record separator, but I am not sure what the various implementations of syslog actually do if they encounter it. We should probably do what the majority of those other implementations do by default as well, for whatever that is... Reproducer: 1. Add following four lines to /etc/rsyslog.conf -- $EscapeControlCharactersOnReceive off $ActionFileDefaultTemplate RSYSLOG_SysklogdFileFormat $SpaceLFOnReceive on $DropTrailingLFOnReception off What does rsyslog do by default without these options? It just throws away anything after the \n -- 3. Restart rsyslog # service rsyslog restart 4. Compile and run the following program -- #include stdio.h #include syslog.h int main() { syslog(LOG_INFO, aaa%caaa, '\n'); return 0; } -- Hmm, what happens if you passs \n inside the static string directly? Why the work-around via %c? How does that change behaviour? I just copied the example from the bug report, but you get the same behavior by using: syslog(LOG_INFO, aaa\naaa); (I am not against this patch, just trying to figure out the precise implications...) Lennart ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] journal: handle multiline syslog messages
On 08/06/2013 11:32 AM, Harald Hoyer wrote: On 08/05/2013 02:12 PM, Lennart Poettering wrote: On Thu, 01.08.13 12:22, har...@redhat.com (har...@redhat.com) wrote: From: Harald Hoyer har...@redhat.com 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. So, hmm. I am a bit concerned about this as syslog-over-stream uses NL as a record separator. syslog-over-dgram doesn't need it as record separator, but I am not sure what the various implementations of syslog actually do if they encounter it. We should probably do what the majority of those other implementations do by default as well, for whatever that is... Reproducer: 1. Add following four lines to /etc/rsyslog.conf -- $EscapeControlCharactersOnReceive off $ActionFileDefaultTemplate RSYSLOG_SysklogdFileFormat $SpaceLFOnReceive on $DropTrailingLFOnReception off What does rsyslog do by default without these options? It just throws away anything after the \n -- 3. Restart rsyslog # service rsyslog restart 4. Compile and run the following program -- #include stdio.h #include syslog.h int main() { syslog(LOG_INFO, aaa%caaa, '\n'); return 0; } -- Hmm, what happens if you passs \n inside the static string directly? Why the work-around via %c? How does that change behaviour? I just copied the example from the bug report, but you get the same behavior by using: syslog(LOG_INFO, aaa\naaa); (I am not against this patch, just trying to figure out the precise implications...) Lennart pushed upstream ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] journal: handle multiline syslog messages
On Thu, 01.08.13 12:22, har...@redhat.com (har...@redhat.com) wrote: From: Harald Hoyer har...@redhat.com 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. So, hmm. I am a bit concerned about this as syslog-over-stream uses NL as a record separator. syslog-over-dgram doesn't need it as record separator, but I am not sure what the various implementations of syslog actually do if they encounter it. We should probably do what the majority of those other implementations do by default as well, for whatever that is... Reproducer: 1. Add following four lines to /etc/rsyslog.conf -- $EscapeControlCharactersOnReceive off $ActionFileDefaultTemplate RSYSLOG_SysklogdFileFormat $SpaceLFOnReceive on $DropTrailingLFOnReception off What does rsyslog do by default without these options? -- 3. Restart rsyslog # service rsyslog restart 4. Compile and run the following program -- #include stdio.h #include syslog.h int main() { syslog(LOG_INFO, aaa%caaa, '\n'); return 0; } -- Hmm, what happens if you passs \n inside the static string directly? Why the work-around via %c? How does that change behaviour? (I am not against this patch, just trying to figure out the precise implications...) Lennart -- Lennart Poettering - Red Hat, Inc. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] journal: handle multiline syslog messages
From: Harald Hoyer har...@redhat.com 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 stdio.h #include syslog.h 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 821935c..f417059 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -1240,12 +1240,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.); -- 1.8.3.1 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel