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

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