]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(dracut-logger): disable kernel logging if /dev/kmsg is not writable
authorBenjamin Drung <benjamin.drung@canonical.com>
Sat, 31 Jan 2026 18:54:39 +0000 (19:54 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Wed, 4 Feb 2026 12:50:59 +0000 (07:50 -0500)
`/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.

dracut-logger.sh

index 321825f2732a31228ddc3e98d50361c1c752e26b..fb64bfbf56465aa1437feeb44e66547d1794ed77 100644 (file)
@@ -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