Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-14900

"needs-restarting -r" reports no reboot required if RTC is not in UTC

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • dnf-plugins-core-4.3.0-18.el9
    • None
    • Moderate
    • rhel-swm
    • ssg_core_services
    • 13
    • 16
    • 8
    • False
    • False
    • Hide

      None

      Show
      None
    • Yes
    • Red Hat Enterprise Linux
    • None
    • Bug Fix
    • Hide
      .`dnf needs-restarting --reboothint` now correctly reports whether a reboot is needed on systems with a real-time clock not running in UTC

      Before this update, if you updated a package which required a system reboot to fully apply the update on a system with a real time clock not running in UTC, the `dnf needs-restarting --reboothint` command might not have reported that the reboot was needed. With this update, the `systemd` UnitsLoadStartTimestamp property is added as a preferred source of a boot time. As a result, `dnf needs-restarting --reboothint` is now more reliable outside of containers on systems with a real-time clock running in local time.
      Show
      .`dnf needs-restarting --reboothint` now correctly reports whether a reboot is needed on systems with a real-time clock not running in UTC Before this update, if you updated a package which required a system reboot to fully apply the update on a system with a real time clock not running in UTC, the `dnf needs-restarting --reboothint` command might not have reported that the reboot was needed. With this update, the `systemd` UnitsLoadStartTimestamp property is added as a preferred source of a boot time. As a result, `dnf needs-restarting --reboothint` is now more reliable outside of containers on systems with a real-time clock running in local time.
    • Done
    • None

      What were you trying to do that didn't work?

      After installing a critical component such as systemd or the kernel, "needs-restarting -r" still reports no reboot is necessary:

      # yum -y reinstall systemd
      [...]
      # needs-restarting -r
      [...]
      No core libraries or services have been updated since boot-up.
      Reboot should not be necessary.

      The issue happens if RTC is in local timezone, which is not recommended but supported anyway.

      This is because internally the tool checks the boot time through using "stat -c %Y /proc/1" python equivalent, then compares installed packages with the boot timestamp.

      Unfortunately this doesn't work because "stat -c %Y /proc/1"  gets somehow adjusted by the kernel because of RTC being in local timezone.

      When timezone is +something, e.g. Europe/Paris, the boot time gets computed in the future:

      # date
      Fri Oct 27 15:15:04 CEST 2023
      
      # stat -c %y /proc/1
      2023-10-27 17:07:50.352000000 +0200
      
      # stat -c %Y /proc/1
      1698419270

      The solution is to instead rely on btime field found in /proc/stat, which seems always correct:

      # grep ^btime /proc/stat 
      btime 1698412068 

      Please provide the package NVR for which bug is seen:

      python3-dnf-plugins-core-4.0.21-19.el8_8.noarch

      How reproducible:

      Always

      Steps to reproduce

      1. Assuming TZ is >UTC (e.g. Europe/Paris) configure the system with local RTC
        # timedatectl set-local-rtc 1
      2. Reboot
        # reboot
      3. Reinstall systemd package
        # yum -y reinstall systemd
      4. Execute needs-restarting -r
        # needs-restarting -r

      Expected results

      Core libraries or services have been updated since boot-up:
        * systemd
      
      Reboot is required to fully utilize these updates.

      Actual results

      No core libraries or services have been updated since boot-up.
      Reboot should not be necessary.

              rh-ee-egoode Evan Goode
              rhn-support-rmetrich Renaud Métrich
              packaging-team-maint packaging-team-maint
              Eva Mrakova Eva Mrakova
              Mariya Pershina Mariya Pershina
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: