def main(args): (opts, args) = parseargs(args) myuid = os.geteuid() if myuid and not opts.useronly: print >>sys.stderr, "Please run as root or with --useronly option" sys.exit(1) my = yum.YumBase() my.preconf.init_plugins=False if hasattr(my, 'setCacheDir'): my.setCacheDir() my.conf.cache = True needing_restart = set() boot_time = utils.get_boot_time() for pid in return_running_pids(uid=myuid): try: pid_start = utils.get_process_time(int(pid), boot_time)['start_time'] except (OSError, IOError), e: continue found_match = False for fn in get_open_files(pid): if found_match: break just_fn = fn.replace('(deleted)', '') just_fn = just_fn.strip() bogon = False # if the file is in a pkg which has been updated since we started the pid - then it needs to be restarted for pkg in my.rpmdb.searchFiles(just_fn): if float(pkg.installtime) > float(pid_start): needing_restart.add(pid) found_match = True continue if just_fn in pkg.ghostlist: bogon = True break if bogon: continue # if the file is deleted if fn.find('(deleted)') != -1: # and it is from /*bin/* then it needs to be restarted if yum.misc.re_primary_filename(just_fn): needing_restart.add(pid) found_match = True continue # if the file is from an old ver of an installed pkg - then assume it was just updated but the # new pkg doesn't have the same file names. Fabulous huh?! my.conf.cache = False for oldpkg in my.pkgSack.searchFiles(just_fn): # ghostfiles are always bogons if just_fn in oldpkg.ghostlist: continue if my.rpmdb.installed(oldpkg.name): needing_restart.add(pid) found_match = True break
def main(args): (opts, args) = parseargs(args) myuid = os.geteuid() if myuid and not opts.useronly: print >>sys.stderr, "Please run as root or with --useronly option" sys.exit(1) my = yum.YumBase() my.preconf.init_plugins=False if hasattr(my, 'setCacheDir'): my.setCacheDir() my.conf.cache = True needing_restart = [] boot_time = utils.get_boot_time() for pid in return_running_pids(uid=myuid): try: pid_start = utils.get_process_time(int(pid), boot_time)['start_time'] except (OSError, IOError), e: continue found_match = False for fn in get_open_files(pid): if found_match: break just_fn = fn.replace('(deleted)', '') just_fn = just_fn.strip() bogon = False # if the file is in a pkg which has been updated since we started the pid - then it needs to be restarted for pkg in my.rpmdb.searchFiles(just_fn): if float(pkg.installtime) > float(pid_start): needing_restart.append([pid, just_fn, pkg.name]) found_match = True continue if just_fn in pkg.ghostlist: bogon = True break if bogon: continue # if the file is deleted if fn.find('(deleted)') != -1: # and it is from /*bin/* then it needs to be restarted if yum.misc.re_primary_filename(just_fn): needing_restart.append([pid, just_fn, pkg.name]) found_match = True continue # if the file is from an old ver of an installed pkg - then assume it was just updated but the # new pkg doesn't have the same file names. Fabulous huh?! my.conf.cache = False for oldpkg in my.pkgSack.searchFiles(just_fn): # ghostfiles are always bogons if just_fn in oldpkg.ghostlist: continue if my.rpmdb.installed(oldpkg.name): needing_restart.append([pid, just_fn, pkg.name]) found_match = True break
def main(args): (opts, args) = parseargs(args) myuid = os.geteuid() if myuid and not opts.useronly: print >> sys.stderr, "Please run as root or with --useronly option" sys.exit(1) my = yum.YumBase() my.preconf.init_plugins = False if hasattr(my, 'setCacheDir'): my.setCacheDir() my.conf.cache = True boot_time = utils.get_boot_time() if opts.reboothint: needing_reboot = set() for pkg in my.rpmdb.searchNames(REBOOTPKGS): if float(pkg.installtime) > float(boot_time): needing_reboot.add(pkg) if needing_reboot: print 'Core libraries or services have been updated:' for pkg in needing_reboot: print ' %s ->' % pkg.name, pkg.printVer() print print 'Reboot is required to ensure that your system benefits', print 'from these updates.' print print 'More information:' print 'https://access.redhat.com/solutions/27943' return 1 else: print 'No core libraries or services have been updated.' print 'Reboot is probably not necessary.' return 0 needing_restart = set() for pid in return_running_pids(uid=myuid): try: pid_start = utils.get_process_time(int(pid), boot_time)['start_time'] except (OSError, IOError), e: continue found_match = False for fn in get_open_files(pid): if found_match: break just_fn = fn.replace('(deleted)', '') just_fn = just_fn.strip() bogon = False # if the file is in a pkg which has been updated since we started the pid - then it needs to be restarted for pkg in my.rpmdb.searchFiles(just_fn): if float(pkg.installtime) > float(pid_start): needing_restart.add(pid) found_match = True continue if just_fn in pkg.ghostlist: bogon = True break if bogon: continue # if the file is deleted if fn.find('(deleted)') != -1: # and it is from /*bin/* then it needs to be restarted if yum.misc.re_primary_filename(just_fn): needing_restart.add(pid) found_match = True continue # if the file is from an old ver of an installed pkg - then assume it was just updated but the # new pkg doesn't have the same file names. Fabulous huh?! my.conf.cache = False for oldpkg in my.pkgSack.searchFiles( just_fn): # ghostfiles are always bogons if just_fn in oldpkg.ghostlist: continue if my.rpmdb.installed(oldpkg.name): needing_restart.add(pid) found_match = True break
def main(args): (opts, args) = parseargs(args) myuid = os.geteuid() if myuid and not opts.useronly: print >>sys.stderr, "Please run as root or with --useronly option" sys.exit(1) my = yum.YumBase() my.preconf.init_plugins=False if hasattr(my, 'setCacheDir'): my.setCacheDir() my.conf.cache = True boot_time = utils.get_boot_time() if opts.reboothint: needing_reboot = set() for pkg in my.rpmdb.searchNames(REBOOTPKGS): if float(pkg.installtime) > float(boot_time): needing_reboot.add(pkg) if needing_reboot: print 'Core libraries or services have been updated:' for pkg in needing_reboot: print ' %s ->' % pkg.name, pkg.printVer() print print 'Reboot is required to ensure that your system benefits', print 'from these updates.' print print 'More information:' print 'https://access.redhat.com/solutions/27943' return 1 else: print 'No core libraries or services have been updated.' print 'Reboot is probably not necessary.' return 0 needing_restart = set() for pid in return_running_pids(uid=myuid): try: pid_start = utils.get_process_time(int(pid), boot_time)['start_time'] except (OSError, IOError), e: continue found_match = False for fn in get_open_files(pid): if found_match: break just_fn = fn.replace('(deleted)', '') just_fn = just_fn.strip() bogon = False # if the file is in a pkg which has been updated since we started the pid - then it needs to be restarted for pkg in my.rpmdb.searchFiles(just_fn): if float(pkg.installtime) > float(pid_start): needing_restart.add(pid) found_match = True continue if just_fn in pkg.ghostlist: bogon = True break if bogon: continue # if the file is deleted if fn.find('(deleted)') != -1: # and it is from /*bin/* then it needs to be restarted if yum.misc.re_primary_filename(just_fn): needing_restart.add(pid) found_match = True continue # if the file is from an old ver of an installed pkg - then assume it was just updated but the # new pkg doesn't have the same file names. Fabulous huh?! my.conf.cache = False for oldpkg in my.pkgSack.searchFiles(just_fn): # ghostfiles are always bogons if just_fn in oldpkg.ghostlist: continue if my.rpmdb.installed(oldpkg.name): needing_restart.add(pid) found_match = True break