diff options
| author | Changqing Li <changqing.li@windriver.com> | 2023-09-05 11:05:27 +0800 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2023-09-08 16:09:42 -1000 |
| commit | 963908553b9c3499bfc35314263769345e8bc7f0 (patch) | |
| tree | 3f62baabf0873e293ab7e75895515f000e7f6ed0 | |
| parent | 4bf9d11c4b09e4ff7fd140530dd7e43aa7ee6312 (diff) | |
| download | poky-963908553b9c3499bfc35314263769345e8bc7f0.tar.gz | |
sysklogd: fix integration with systemd-journald
Fix an issue with early log messages being lost when running in systemd.
(From OE-Core rev: 47a1dd7f389e3cf4ac2dc5fc21dccc870aafab4a)
Signed-off-by: Changqing Li <changqing.li@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
3 files changed, 110 insertions, 0 deletions
diff --git a/meta/recipes-extended/sysklogd/files/0001-syslogd.service-KillMode-process-is-not-recommended-.patch b/meta/recipes-extended/sysklogd/files/0001-syslogd.service-KillMode-process-is-not-recommended-.patch new file mode 100644 index 0000000000..6c7e7cea44 --- /dev/null +++ b/meta/recipes-extended/sysklogd/files/0001-syslogd.service-KillMode-process-is-not-recommended-.patch | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | From b732dd0001c66f3ff1e0aef919c84ca9f0f81252 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Joachim Wiberg <troglobit@gmail.com> | ||
| 3 | Date: Sat, 22 Apr 2023 07:40:24 +0200 | ||
| 4 | Subject: [PATCH 1/2] syslogd.service: KillMode=process is not recommended, | ||
| 5 | drop | ||
| 6 | |||
| 7 | The default 'control-group' ensures all processes started by sysklogd | ||
| 8 | are stopped when the service is stopped, this is what we want. | ||
| 9 | |||
| 10 | Signed-off-by: Joachim Wiberg <troglobit@gmail.com> | ||
| 11 | |||
| 12 | Upstream-Status: Backport [https://github.com/troglobit/sysklogd/commit/c82c004de7e25e770039cba5d6a34c30dd548533] | ||
| 13 | |||
| 14 | Signed-off-by: Changqing Li <changqing.li@windriver.com> | ||
| 15 | --- | ||
| 16 | syslogd.service.in | 1 - | ||
| 17 | 1 file changed, 1 deletion(-) | ||
| 18 | |||
| 19 | diff --git a/syslogd.service.in b/syslogd.service.in | ||
| 20 | index 91e080a..d614c5f 100644 | ||
| 21 | --- a/syslogd.service.in | ||
| 22 | +++ b/syslogd.service.in | ||
| 23 | @@ -9,7 +9,6 @@ EnvironmentFile=-@SYSCONFDIR@/default/syslogd | ||
| 24 | ExecStart=@SBINDIR@/syslogd -F -p /run/systemd/journal/syslog $SYSLOGD_OPTS | ||
| 25 | StandardOutput=null | ||
| 26 | Restart=on-failure | ||
| 27 | -KillMode=process | ||
| 28 | |||
| 29 | [Install] | ||
| 30 | WantedBy=multi-user.target | ||
| 31 | -- | ||
| 32 | 2.25.1 | ||
| 33 | |||
diff --git a/meta/recipes-extended/sysklogd/files/0002-Fix-62-early-log-messages-lost-when-running-in-syste.patch b/meta/recipes-extended/sysklogd/files/0002-Fix-62-early-log-messages-lost-when-running-in-syste.patch new file mode 100644 index 0000000000..78ae57eeeb --- /dev/null +++ b/meta/recipes-extended/sysklogd/files/0002-Fix-62-early-log-messages-lost-when-running-in-syste.patch | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | From ba8156eab79784ef816958327e701923890e98f7 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Joachim Wiberg <troglobit@gmail.com> | ||
| 3 | Date: Sat, 22 Apr 2023 08:27:57 +0200 | ||
| 4 | Subject: [PATCH 2/2] Fix #62: early log messages lost when running in systemd | ||
| 5 | |||
| 6 | This is a follow-up to d7576c7 which initially added support for running | ||
| 7 | in systemd based systems. Since the unit file sources the syslog.socket | ||
| 8 | we have /run/systemd/journal/syslog open already on descriptor 3. All | ||
| 9 | we need to do is verify that's the mode syslogd runs in. | ||
| 10 | |||
| 11 | Signed-off-by: Joachim Wiberg <troglobit@gmail.com> | ||
| 12 | |||
| 13 | Upstream-Status: Backport [https://github.com/troglobit/sysklogd/commit/7ec64e5f9c1bc284792d028647fb36ef3e64dff7] | ||
| 14 | |||
| 15 | Signed-off-by: Changqing Li <changqing.li@windriver.com> | ||
| 16 | --- | ||
| 17 | src/syslogd.c | 21 +++++++++++++++------ | ||
| 18 | syslogd.service.in | 2 +- | ||
| 19 | 2 files changed, 16 insertions(+), 7 deletions(-) | ||
| 20 | |||
| 21 | diff --git a/src/syslogd.c b/src/syslogd.c | ||
| 22 | index fa4303f..e96ca9a 100644 | ||
| 23 | --- a/src/syslogd.c | ||
| 24 | +++ b/src/syslogd.c | ||
| 25 | @@ -162,6 +162,7 @@ void untty(void); | ||
| 26 | static void parsemsg(const char *from, char *msg); | ||
| 27 | static int opensys(const char *file); | ||
| 28 | static void printsys(char *msg); | ||
| 29 | +static void unix_cb(int sd, void *arg); | ||
| 30 | static void logmsg(struct buf_msg *buffer); | ||
| 31 | static void fprintlog_first(struct filed *f, struct buf_msg *buffer); | ||
| 32 | static void fprintlog_successive(struct filed *f, int flags); | ||
| 33 | @@ -436,12 +437,20 @@ int main(int argc, char *argv[]) | ||
| 34 | .pe_serv = "syslog", | ||
| 35 | }); | ||
| 36 | |||
| 37 | - /* Default to _PATH_LOG for the UNIX domain socket */ | ||
| 38 | - if (!pflag) | ||
| 39 | - addpeer(&(struct peer) { | ||
| 40 | - .pe_name = _PATH_LOG, | ||
| 41 | - .pe_mode = 0666, | ||
| 42 | - }); | ||
| 43 | + /* Figure out where to read system log messages from */ | ||
| 44 | + if (!pflag) { | ||
| 45 | + /* Do we run under systemd-journald (Requires=syslog.socket)? */ | ||
| 46 | + if (fcntl(3, F_GETFD) != -1) { | ||
| 47 | + if (socket_register(3, NULL, unix_cb, NULL) == -1) | ||
| 48 | + err(1, "failed registering syslog.socket (3)"); | ||
| 49 | + } else { | ||
| 50 | + /* Default to _PATH_LOG for the UNIX domain socket */ | ||
| 51 | + addpeer(&(struct peer) { | ||
| 52 | + .pe_name = _PATH_LOG, | ||
| 53 | + .pe_mode = 0666, | ||
| 54 | + }); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | |||
| 58 | if (!Foreground && !Debug) { | ||
| 59 | ppid = waitdaemon(30); | ||
| 60 | diff --git a/syslogd.service.in b/syslogd.service.in | ||
| 61 | index d614c5f..bc82af9 100644 | ||
| 62 | --- a/syslogd.service.in | ||
| 63 | +++ b/syslogd.service.in | ||
| 64 | @@ -6,7 +6,7 @@ Requires=syslog.socket | ||
| 65 | |||
| 66 | [Service] | ||
| 67 | EnvironmentFile=-@SYSCONFDIR@/default/syslogd | ||
| 68 | -ExecStart=@SBINDIR@/syslogd -F -p /run/systemd/journal/syslog $SYSLOGD_OPTS | ||
| 69 | +ExecStart=@SBINDIR@/syslogd -F $SYSLOGD_OPTS | ||
| 70 | StandardOutput=null | ||
| 71 | Restart=on-failure | ||
| 72 | |||
| 73 | -- | ||
| 74 | 2.25.1 | ||
| 75 | |||
diff --git a/meta/recipes-extended/sysklogd/sysklogd_2.3.0.bb b/meta/recipes-extended/sysklogd/sysklogd_2.3.0.bb index 7043f3d391..0dc5ef93e2 100644 --- a/meta/recipes-extended/sysklogd/sysklogd_2.3.0.bb +++ b/meta/recipes-extended/sysklogd/sysklogd_2.3.0.bb | |||
| @@ -12,6 +12,8 @@ inherit update-rc.d update-alternatives systemd autotools | |||
| 12 | 12 | ||
| 13 | SRC_URI = "git://github.com/troglobit/sysklogd.git;branch=master;protocol=https \ | 13 | SRC_URI = "git://github.com/troglobit/sysklogd.git;branch=master;protocol=https \ |
| 14 | file://sysklogd \ | 14 | file://sysklogd \ |
| 15 | file://0001-syslogd.service-KillMode-process-is-not-recommended-.patch \ | ||
| 16 | file://0002-Fix-62-early-log-messages-lost-when-running-in-syste.patch \ | ||
| 15 | " | 17 | " |
| 16 | 18 | ||
| 17 | SRCREV = "03c2c9c68d5d02675326527774e7e9cba3490ba0" | 19 | SRCREV = "03c2c9c68d5d02675326527774e7e9cba3490ba0" |
