From: Benjamin Drung Date: Sat, 31 Jan 2026 18:54:39 +0000 (+0100) Subject: fix(dracut-logger): disable kernel logging if /dev/kmsg is not writable X-Git-Tag: 110~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49c32f9f05643ca41a6b1685e03a28db8c9a92e3;p=thirdparty%2Fdracut-ng.git fix(dracut-logger): disable kernel logging if /dev/kmsg is not writable `/dev/kmsg` is might not be writable (for example in a podman container). So disable trying to log to the kernel ring buffer in that case. --- diff --git a/dracut-logger.sh b/dracut-logger.sh index 321825f27..fb64bfbf5 100644 --- a/dracut-logger.sh +++ b/dracut-logger.sh @@ -153,13 +153,21 @@ dlog_init() { exec 15> "$_systemdcatfile" elif ! ([[ -S /dev/log ]] && [[ -w /dev/log ]] && command -v logger > /dev/null); then # We cannot log to syslog, so turn this facility off. - kmsgloglvl=$sysloglvl + if [[ -w /dev/kmsg ]]; then + kmsgloglvl=$sysloglvl + fi sysloglvl=0 ret=1 errmsgs+=("No '/dev/log' or 'logger' included for syslog logging") fi fi + if ((kmsgloglvl > 0)) && [[ ! -w /dev/kmsg ]]; then + kmsgloglvl=0 + ret=1 + errmsgs+=("'/dev/kmsg' not writable. Disabling logging to kernel ring buffer.") + fi + if ((sysloglvl > 0)) || ((kmsgloglvl > 0)); then if [ -n "$dracutbasedir" ]; then readonly syslogfacility=user