busybox: fix for syslog service in systemd
PATCH 1/1 busybox: fix for syslog service in systemd
commit 9943ffeeed5c612d1bc44a12607d553f7704dc7e
Author: Chen Qi <[email protected]> Date: Thu Sep 11 04:55:35 2014 -0400
busybox: fix for syslog service in systemd
This patch includes the following changes:
1. Explicitly set StandardOutput of the log daemon to null. This would avoid creating a feedback loop of the syslog service. See link below for more information.
http://www.freedesktop.org/wiki/Software/systemd/syslog/
2. Use ALTERNATIVE machanism to manage the syslog service file. This is because that other package may also provide a syslog implementation.
3. Make the syslog daemon socket activated only. Otherwise, things would crash if we install busybox-syslog and other syslog packages together in one image.
commit 425d7b8605612cdc65daf2c1ef6cf5655ad8f227
Author: Yadi.hu <[email protected]> Date: Wed Jun 1 17:54:17 2016 -0700
busybox: handle syslog
If CONFIG_KLOGD is not enabled, then the related service file should not be installed, The error message is below:
Cannot add dependency job for unit busybox-klogd.service,
ignoring: Unit busybox-klogd.service failed to load:
No such file or directory.
So we should first check the configuration before we install these service files.
PATCH 1/2 busybox: fix for syslog service in systemd
This patch includes the following changes:
1. Explicitly set StandardOutput of the log daemon to null. This would avoid creating a feedback loop of the syslog service. See link below for more information.
http://www.freedesktop.org/wiki/Software/systemd/syslog/
2. Use ALTERNATIVE machanism to manage the syslog service file. This is because that other package may also provide a syslog implementation.
3. Make the syslog daemon socket activated only. Otherwise, things would crash if we install busybox-syslog and other syslog packages together in one image.
--- meta/recipes-core/busybox/busybox.inc | 9 +++++++-- meta/recipes-core/busybox/files/busybox-klogd.service.in | 4 +--- meta/recipes-core/busybox/files/busybox-syslog.service.in | 7 +++---- 3 files changed, 11 insertions(+), 9 deletions(-)
meta/recipes-core/busybox/busybox.inc +7 -2
@@ -295,13 +295,12 @@ do_install () { if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then install -d ${D}${systemd_unitdir}/system - sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-syslog.service.in \ + sed -e 's,@base_sbindir@,${base_sbindir},g' -e 's,@SYSCONFDIR@,${sysconfdir},g' < ${WORKDIR}/busybox-syslog.service.in \ > ${D}${systemd_unitdir}/system/busybox-syslog.service if [ -f ${WORKDIR}/busybox-syslog.default ] ; then install -d ${D}${sysconfdir}/default install -m 0644 ${WORKDIR}/busybox-syslog.default ${D}${sysconfdir}/default/busybox-syslog fi - ln -sf /dev/null ${D}${systemd_unitdir}/system/syslog.service fi if grep -q "CONFIG_KLOGD=y" ${B}/.config; then install -d ${D}${systemd_unitdir}/system
@@ -338,6 +337,12 @@ python () { d.appendVar('ALTERNATIVE_%s-syslog' % (pn), ' syslog-startup-conf') d.setVarFlag('ALTERNATIVE_LINK_NAME', 'syslog-startup-conf', '%s/syslog-startup.conf' % (d.getVar('sysconfdir', True))) d.setVarFlag('ALTERNATIVE_TARGET', 'syslog-startup-conf', '%s/syslog-startup.conf.%s' % (d.getVar('sysconfdir', True), d.getVar('BPN', True))) + + if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d): + pn = d.getVar('PN', True) + d.appendVar('ALTERNATIVE_%s-syslog' % (pn), ' syslog-service') + d.setVarFlag('ALTERNATIVE_LINK_NAME', 'syslog-service', '%s/systemd/system/syslog.service' % (d.getVar('sysconfdir', True))) + d.setVarFlag('ALTERNATIVE_TARGET', 'syslog-service', '%s/system/busybox-syslog.service' % (d.getVar('systemd_unitdir', True))) } python do_package_prepend () {
meta/recipes-core/busybox/files/busybox-klogd.service.in +1 -3
@@ -3,6 +3,4 @@ Description=Kernel Logging Service [Service] ExecStart=@base_sbindir@/klogd -n - -[Install] -WantedBy=multi-user.target +StandardOutput=null
meta/recipes-core/busybox/files/busybox-syslog.service.in +3 -4
@@ -1,13 +1,12 @@ [Unit] Description=System Logging Service Wants=busybox-klogd.service +Requires=syslog.socket [Service] -EnvironmentFile=-/etc/default/busybox-syslog +EnvironmentFile=-@SYSCONFDIR@/default/busybox-syslog ExecStart=@base_sbindir@/syslogd -n $OPTIONS -Sockets=syslog.socket +StandardOutput=null [Install] -WantedBy=multi-user.target Also=busybox-klogd.service -Alias=syslog.service
Signature · 1 line
2.8.1
Quoted 59 lines · On 07/26/2016 02:33 AM, [email protected] wrote:
This patch includes the following changes:
1. Explicitly set StandardOutput of the log daemon to null. This would avoid creating a feedback loop of the syslog service. See link below for more information.
http://www.freedesktop.org/wiki/Software/systemd/syslog/2. Use ALTERNATIVE machanism to manage the syslog service file. This is because that other package may also provide a syslog implementation.
3. Make the syslog daemon socket activated only. Otherwise, things would crash if we install busybox-syslog and other syslog packages together in one image.
Signed-off-by Chen Qi <[email protected]>Signed-off-by Mingli Yu <[email protected]>--- meta/recipes-core/busybox/busybox.inc | 9 +++++++-- meta/recipes-core/busybox/files/busybox-klogd.service.in | 4 +--- meta/recipes-core/busybox/files/busybox-syslog.service.in | 7 +++---- 3 files changed, 11 insertions(+), 9 deletions(-)meta/recipes-core/busybox/busybox.inc +7
-2@@ -295,13 +295,12 @@ do_install () { if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then install -d ${D}${systemd_unitdir}/system - sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-syslog.service.in \ + sed -e 's,@base_sbindir@,${base_sbindir},g' -e 's,@SYSCONFDIR@,${sysconfdir},g' < ${WORKDIR}/busybox-syslog.service.in \ > ${D}${systemd_unitdir}/system/busybox-syslog.service if [ -f ${WORKDIR}/busybox-syslog.default ] ; then install -d ${D}${sysconfdir}/default install -m 0644 ${WORKDIR}/busybox-syslog.default ${D}${sysconfdir}/default/busybox-syslog fi - ln -sf /dev/null ${D}${systemd_unitdir}/system/syslog.service fi if grep -q "CONFIG_KLOGD=y" ${B}/.config; then install -d ${D}${systemd_unitdir}/system@@ -338,6 +337,12 @@ python () { d.appendVar('ALTERNATIVE_%s-syslog' % (pn), ' syslog-startup-conf') d.setVarFlag('ALTERNATIVE_LINK_NAME', 'syslog-startup-conf', '%s/syslog-startup.conf' % (d.getVar('sysconfdir', True))) d.setVarFlag('ALTERNATIVE_TARGET', 'syslog-startup-conf', '%s/syslog-startup.conf.%s' % (d.getVar('sysconfdir', True), d.getVar('BPN', True))) + + if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d): + pn = d.getVar('PN', True) + d.appendVar('ALTERNATIVE_%s-syslog' % (pn), ' syslog-service') + d.setVarFlag('ALTERNATIVE_LINK_NAME', 'syslog-service', '%s/systemd/system/syslog.service' % (d.getVar('sysconfdir', True))) + d.setVarFlag('ALTERNATIVE_TARGET', 'syslog-service', '%s/system/busybox-syslog.service' % (d.getVar('systemd_unitdir', True))) } python do_package_prepend () {meta/recipes-core/busybox/files/busybox-klogd.service.in +0
-0
meta/recipes-core/busybox/files/busybox-klogd.service.in Description=Kernel Logging Service · line 8
Quoted 6 lines
meta/recipes-core/busybox/files/busybox-klogd.service.in +0
-3@@ -3,6 +3,4 @@ Description=Kernel Logging Service [Service] ExecStart=@base_sbindir@/klogd -n - -[Install] -WantedBy=multi-user.target
Hi Mingil,
This commit breaks the build when was tested in master-next [1], i guess you are trying to use another syslog service in busybox images but when you disable busybox-syslog for start by default (line below) the sanity testing fails.
Quoted 10 lines
meta/recipes-core/busybox/files/busybox-klogd.service.in +1
-0+StandardOutput=nullmeta/recipes-core/busybox/files/busybox-syslog.service.in +1
-0@@ -1,13 +1,12 @@ [Unit] Description=System Logging Service Wants=busybox-klogd.service +Requires=syslog.socket
meta/recipes-core/busybox/files/busybox-syslog.service.in line 11
Quoted 10 lines
meta/recipes-core/busybox/files/busybox-syslog.service.in +2
-3[Service] -EnvironmentFile=-/etc/default/busybox-syslog +EnvironmentFile=-@SYSCONFDIR@/default/busybox-syslog ExecStart=@base_sbindir@/syslogd -n $OPTIONS -Sockets=syslog.socket +StandardOutput=null [Install] -WantedBy=multi-user.target
The same here,
Kind regards,
alimon
Quoted 3 lines
meta/recipes-core/busybox/files/busybox-syslog.service.in +0
-1Also=busybox-klogd.service -Alias=syslog.service
PATCH 2/2 busybox: handle syslog
In reply to [email protected]If CONFIG_KLOGD is not enabled, then the related service file should not be installed, The error message is below:
Cannot add dependency job for unit busybox-klogd.service,
ignoring: Unit busybox-klogd.service failed to load:
No such file or directory.
So we should first check the configuration before we install these service files.
--- meta/recipes-core/busybox/busybox.inc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
meta/recipes-core/busybox/busybox.inc +9 -5
@@ -293,20 +293,24 @@ do_install () { fi if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + if grep -q "CONFIG_KLOGD=y" ${B}/.config; then + install -d ${D}${systemd_unitdir}/system + sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-klogd.service.in \ + > ${D}${systemd_unitdir}/system/busybox-klogd.service + fi + if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then install -d ${D}${systemd_unitdir}/system sed -e 's,@base_sbindir@,${base_sbindir},g' -e 's,@SYSCONFDIR@,${sysconfdir},g' < ${WORKDIR}/busybox-syslog.service.in \ > ${D}${systemd_unitdir}/system/busybox-syslog.service + if [ ! -e ${D}${systemd_unitdir}/system/busybox-klogd.service ] ; then + sed -i '/klog/d' ${D}${systemd_unitdir}/system/busybox-syslog.service + fi if [ -f ${WORKDIR}/busybox-syslog.default ] ; then install -d ${D}${sysconfdir}/default install -m 0644 ${WORKDIR}/busybox-syslog.default ${D}${sysconfdir}/default/busybox-syslog fi fi - if grep -q "CONFIG_KLOGD=y" ${B}/.config; then - install -d ${D}${systemd_unitdir}/system - sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-klogd.service.in \ - > ${D}${systemd_unitdir}/system/busybox-klogd.service - fi fi # Remove the sysvinit specific configuration file for systemd systems to avoid confusion
Signature · 1 line
2.8.1