Skip to content

RPM reboot detection fails on RHEL 8/9 when /boot/vmlinuz symlink is absent #864

Description

@sr-rossanderson

Patchman can fail to report a required reboot on modern RHEL 8/9 systems.

I encountered this on a RHEL 9 host after patching. The host was running an older kernel than the newest installed kernel and dnf needs-restarting -r correctly reported that a reboot was required, but Patchman reported no reboot requirement.

Example:

$ cat /proc/sys/kernel/osrelease
5.14.0-611.54.1.el9_7.x86_64

$ rpm -q kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -V
5.14.0-611.36.1.el9_7.x86_64
5.14.0-611.54.1.el9_7.x86_64
5.14.0-687.44.1.el9_8.x86_64

$ ls -l /boot/vmlinuz
ls: cannot access '/boot/vmlinuz': No such file or directory

dnf needs-restarting -r reports that a reboot is required.

Current behaviour

patchman-client checks /var/run/reboot-required and then compares the running kernel against a /boot/vmlinuz symlink.

On RHEL 8/9, /boot/vmlinuz may not exist as a symlink. In that case the client falls back to:

reboot=ServerCheck

Protocol 2 converts reboot state to a boolean and only sends true when the value is exactly True. ServerCheck therefore becomes:

"reboot_required": false

This produces a false negative.

Expected behaviour

On RPM/DNF systems, Patchman should reliably detect whether a reboot is required.

A suitable method on current RHEL systems is:

dnf needs-restarting -r

where:

0 = reboot not required
1 = reboot required

If dnf needs-restarting is unavailable or returns an unexpected status, Patchman can fall back to its existing logic.

Suggested approach

Conceptually:

if command -v dnf >/dev/null 2>&1; then
    dnf needs-restarting -r >/dev/null 2>&1
    rc=$?

    if [ "$rc" -eq 1 ]; then
        reboot=True
        return
    elif [ "$rc" -eq 0 ]; then
        reboot=False
        return
    fi
fi

It may also be worth preserving the ServerCheck state in Protocol 2 rather than silently serialising an unknown state as false.

Impact

Patchman can incorrectly show that patched RHEL 8/9 hosts do not require a reboot even when a newer kernel and/or reboot-sensitive core components have been installed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions