Blame SOURCES/BZ-1192946-needs-restarting-add-reboothint-opt.patch

fe6837
diff -up yum-utils-1.1.31/docs/needs-restarting.1.orig yum-utils-1.1.31/docs/needs-restarting.1
fe6837
--- yum-utils-1.1.31/docs/needs-restarting.1.orig	2016-08-04 12:17:58.638041851 +0200
fe6837
+++ yum-utils-1.1.31/docs/needs-restarting.1	2016-08-04 12:18:37.479777824 +0200
fe6837
@@ -14,6 +14,8 @@ started running before they or some comp
fe6837
 Display a help message, and then quit.
fe6837
 .IP "\fB\-u, \-\-useronly\fP"
fe6837
 Show processes for my userid only.
fe6837
+.IP "\fB\-r, \-\-reboothint\fP"
fe6837
+Only report whether a full reboot is required (returns 1) or not (returns 0).
fe6837
 
fe6837
 .PP
fe6837
 .SH "SEE ALSO"
fe6837
diff -up yum-utils-1.1.31/needs-restarting.py.orig yum-utils-1.1.31/needs-restarting.py
fe6837
--- yum-utils-1.1.31/needs-restarting.py.orig	2016-08-04 12:17:41.397159047 +0200
fe6837
+++ yum-utils-1.1.31/needs-restarting.py	2016-08-04 12:19:22.944468776 +0200
fe6837
@@ -48,6 +48,11 @@ from yum.Errors import RepoError
fe6837
 sys.path.insert(0,'/usr/share/yum-cli')
fe6837
 import utils
fe6837
 
fe6837
+# For which package updates we should recommend a reboot
fe6837
+# Taken from https://access.redhat.com/solutions/27943
fe6837
+REBOOTPKGS = ['kernel', 'glibc', 'linux-firmware', 'systemd', 'udev',
fe6837
+              'openssl-libs', 'gnutls', 'dbus']
fe6837
+
fe6837
 def parseargs(args):
fe6837
     usage = """
fe6837
     needs-restarting: Report a list of process ids of programs that started 
fe6837
@@ -57,6 +62,9 @@ def parseargs(args):
fe6837
     
fe6837
     parser.add_option("-u", "--useronly", default=False, action="store_true",
fe6837
       help='show processes for my userid only')
fe6837
+    parser.add_option("-r", "--reboothint", default=False, action="store_true",
fe6837
+      help=('only report whether a full reboot is required (returns 1) or not '
fe6837
+            '(returns 0)'))
fe6837
     
fe6837
     (opts, args) = parser.parse_args(args)
fe6837
     return (opts, args)
fe6837
@@ -111,9 +119,30 @@ def main(args):
fe6837
     if opts.useronly:
fe6837
         myuid = os.getuid()
fe6837
     
fe6837
-    needing_restart = set()
fe6837
-
fe6837
     boot_time = utils.get_boot_time()
fe6837
+
fe6837
+    if opts.reboothint:
fe6837
+        needing_reboot = set()
fe6837
+        for pkg in my.rpmdb.searchNames(REBOOTPKGS):
fe6837
+            if float(pkg.installtime) > float(boot_time):
fe6837
+                needing_reboot.add(pkg)
fe6837
+        if needing_reboot:
fe6837
+            print 'Core libraries or services have been updated:'
fe6837
+            for pkg in needing_reboot:
fe6837
+                print '  %s ->' % pkg.name, pkg.printVer()
fe6837
+            print
fe6837
+            print 'Reboot is required to ensure that your system benefits',
fe6837
+            print 'from these updates.'
fe6837
+            print
fe6837
+            print 'More information:'
fe6837
+            print 'https://access.redhat.com/solutions/27943'
fe6837
+            return 1
fe6837
+        else:
fe6837
+            print 'No core libraries or services have been updated.'
fe6837
+            print 'Reboot is probably not necessary.'
fe6837
+            return 0
fe6837
+
fe6837
+    needing_restart = set()
fe6837
     for pid in return_running_pids(uid=myuid):
fe6837
         try:
fe6837
             pid_start = utils.get_process_time(int(pid), boot_time)['start_time']