From 191dfa60195901766052b7d9d63c9cb71f422d94 Mon Sep 17 00:00:00 2001 From: Krish Rathore Date: Fri, 30 Oct 2026 15:54:53 +0530 Subject: [PATCH] use dnf needs-restarting for rpm reboot detection On RHEL 8/9 /boot/vmlinuz is often not a symlink, so the client fell back to ServerCheck, which protocol 2 sends as reboot_required: false. Hosts running an older kernel than the newest installed one were shown as not needing a reboot. When dnf is available, ask `dnf needs-restarting -r`, which also covers core libraries such as glibc and systemd. dnf exits 1 both when a reboot is required and on errors such as the needs-restarting plugin not being installed, so exit 1 only counts when the output says a reboot is required. Any other result falls back to the existing checks. Fixes #864 --- client/patchman-client | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/patchman-client b/client/patchman-client index 9e8615bb..961a5205 100755 --- a/client/patchman-client +++ b/client/patchman-client @@ -720,6 +720,22 @@ reboot_required() { return fi + # RHEL/Fedora: dnf needs-restarting checks the kernel and core libraries. + # It also exits 1 on errors (e.g. plugin not installed), so only trust + # that exit code together with its reboot message. + if check_command_exists dnf ; then + local needs_restarting + needs_restarting=$(LC_ALL=C dnf needs-restarting -r 2>/dev/null) + local rc=$? + if [ ${rc} -eq 0 ] ; then + reboot=False + return + elif [ ${rc} -eq 1 ] && echo "${needs_restarting}" | grep -q 'Reboot is required' ; then + reboot=True + return + fi + fi + # Compare running vs installed kernel via /boot/vmlinuz symlink if [ -e /proc/sys/kernel/osrelease ] && [ -L /boot/vmlinuz ] ; then running_kernel=$(cat /proc/sys/kernel/osrelease)