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

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