|
Pablo Greco |
48fc63 |
From 0adbe0fe7f1cb8703904c85fa095db8070503c04 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
48fc63 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
Pablo Greco |
48fc63 |
Date: Fri, 10 Aug 2018 11:07:54 +0900
|
|
Pablo Greco |
48fc63 |
Subject: [PATCH] journal: do not remove multiple spaces after identifier in
|
|
Pablo Greco |
48fc63 |
syslog message
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
Single space is used as separator.
|
|
Pablo Greco |
48fc63 |
C.f. discussions in #156.
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
Fixes #9839 introduced by a6aadf4ae0bae185dc4c414d492a4a781c80ffe5.
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
(cherry-picked from commit 8595102d3ddde6d25c282f965573a6de34ab4421)
|
|
Pablo Greco |
48fc63 |
Related: #1657794
|
|
Pablo Greco |
48fc63 |
---
|
|
Pablo Greco |
48fc63 |
src/journal/journald-syslog.c | 4 +++-
|
|
Pablo Greco |
48fc63 |
src/journal/test-journal-syslog.c | 24 ++++++++++++++----------
|
|
Pablo Greco |
48fc63 |
2 files changed, 17 insertions(+), 11 deletions(-)
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
|
|
Pablo Greco |
48fc63 |
index 3ea5d79c3a..1a9db59a0f 100644
|
|
Pablo Greco |
48fc63 |
--- a/src/journal/journald-syslog.c
|
|
Pablo Greco |
48fc63 |
+++ b/src/journal/journald-syslog.c
|
|
Pablo Greco |
48fc63 |
@@ -234,7 +234,9 @@ size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid)
|
|
Pablo Greco |
48fc63 |
if (t)
|
|
Pablo Greco |
48fc63 |
*identifier = t;
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
- e += strspn(p + e, WHITESPACE);
|
|
Pablo Greco |
48fc63 |
+ /* Single space is used as separator */
|
|
Pablo Greco |
48fc63 |
+ if (p[e] != '\0' && strchr(WHITESPACE, p[e]))
|
|
Pablo Greco |
48fc63 |
+ e++;
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
*buf = p + e;
|
|
Pablo Greco |
48fc63 |
return e;
|
|
Pablo Greco |
48fc63 |
diff --git a/src/journal/test-journal-syslog.c b/src/journal/test-journal-syslog.c
|
|
Pablo Greco |
48fc63 |
index f56a813774..d4bd8607d3 100644
|
|
Pablo Greco |
48fc63 |
--- a/src/journal/test-journal-syslog.c
|
|
Pablo Greco |
48fc63 |
+++ b/src/journal/test-journal-syslog.c
|
|
Pablo Greco |
48fc63 |
@@ -23,7 +23,7 @@
|
|
Pablo Greco |
48fc63 |
#include "macro.h"
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
static void test_syslog_parse_identifier(const char *str,
|
|
Pablo Greco |
48fc63 |
- const char *ident, const char*pid, int ret) {
|
|
Pablo Greco |
48fc63 |
+ const char *ident, const char *pid, const char *rest, int ret) {
|
|
Pablo Greco |
48fc63 |
const char *buf = str;
|
|
Pablo Greco |
48fc63 |
_cleanup_free_ char *ident2 = NULL, *pid2 = NULL;
|
|
Pablo Greco |
48fc63 |
int ret2;
|
|
Pablo Greco |
48fc63 |
@@ -33,18 +33,22 @@ static void test_syslog_parse_identifier(const char *str,
|
|
Pablo Greco |
48fc63 |
assert_se(ret == ret2);
|
|
Pablo Greco |
48fc63 |
assert_se(ident == ident2 || streq_ptr(ident, ident2));
|
|
Pablo Greco |
48fc63 |
assert_se(pid == pid2 || streq_ptr(pid, pid2));
|
|
Pablo Greco |
48fc63 |
+ assert_se(streq(buf, rest));
|
|
Pablo Greco |
48fc63 |
}
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
int main(void) {
|
|
Pablo Greco |
48fc63 |
- test_syslog_parse_identifier("pidu[111]: xxx", "pidu", "111", 11);
|
|
Pablo Greco |
48fc63 |
- test_syslog_parse_identifier("pidu: xxx", "pidu", NULL, 6);
|
|
Pablo Greco |
48fc63 |
- test_syslog_parse_identifier("pidu: xxx", "pidu", NULL, 7);
|
|
Pablo Greco |
48fc63 |
- test_syslog_parse_identifier("pidu xxx", NULL, NULL, 0);
|
|
Pablo Greco |
48fc63 |
- test_syslog_parse_identifier(":", "", NULL, 1);
|
|
Pablo Greco |
48fc63 |
- test_syslog_parse_identifier(": ", "", NULL, 3);
|
|
Pablo Greco |
48fc63 |
- test_syslog_parse_identifier("pidu:", "pidu", NULL, 5);
|
|
Pablo Greco |
48fc63 |
- test_syslog_parse_identifier("pidu: ", "pidu", NULL, 6);
|
|
Pablo Greco |
48fc63 |
- test_syslog_parse_identifier("pidu : ", NULL, NULL, 0);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier("pidu[111]: xxx", "pidu", "111", "xxx", 11);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier("pidu: xxx", "pidu", NULL, "xxx", 6);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier("pidu: xxx", "pidu", NULL, " xxx", 6);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier("pidu xxx", NULL, NULL, "pidu xxx", 0);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier(" pidu xxx", NULL, NULL, " pidu xxx", 0);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier("", NULL, NULL, "", 0);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier(" ", NULL, NULL, " ", 0);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier(":", "", NULL, "", 1);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier(": ", "", NULL, " ", 2);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier("pidu:", "pidu", NULL, "", 5);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier("pidu: ", "pidu", NULL, "", 6);
|
|
Pablo Greco |
48fc63 |
+ test_syslog_parse_identifier("pidu : ", NULL, NULL, "pidu : ", 0);
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
return 0;
|
|
Pablo Greco |
48fc63 |
}
|