403Webshell
Server IP : 178.212.43.201  /  Your IP : 10.100.0.33
Web Server : Apache/2.4.37 (Oracle Linux Server) OpenSSL/1.1.1k
System : Linux spa0007.srv.paxillus.pl 5.4.17-2136.355.3.1.el8uek.x86_64 #3 SMP Sat May 9 17:11:55 PDT 2026 x86_64
User : apache ( 48)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/dnf-plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/dnf-plugins/ulninfo.py
# coding=utf-8
# ulninfo.py - various client-side operations for ULN

from dnfpluginscore import logger
from copy import copy
from dnf.conf.config import PRIO_PLUGINCONFIG

import up2date_client.config
import up2date_client.rhnChannel
import up2date_client.rhnPackageInfo
import up2date_client.up2dateAuth
import up2date_client.up2dateErrors

import dnf,os,re,sys,urllib

class UlnInfo(dnf.Plugin):
    name = 'ulninfo'

    @staticmethod
    def _out(msg):
        logger.debug('ulninfo plugin: %s', msg)

    def __init__(self, base, cli):
        super(UlnInfo, self).__init__(base, cli)
        self.base = base
        self.conf = copy(self.base.conf)
        self.parser = self.read_config(self.conf)
        
        # pull in all the config values and command options
        if "main" in self.parser.sections():
            options = self.parser.items("main")
            for (key, value) in options:
                self.conf._set_value(key, value, PRIO_PLUGINCONFIG)

        # only display the license info for repolist commands
        prog_name = os.path.basename(sys.argv[0])
        if prog_name in ('yum','dnf'):
            cmd_args = sys.argv[1:]
            if 'repolist' not in cmd_args:
                return

        # verify the system is connected to ULN by checking for the login info
        try:
            login_info = up2date_client.up2dateAuth.getLoginInfo(timeout=self.conf.timeout)
        except Exception:
            return

        # if no login info, system not registered, die quietly
        if not login_info:
            return

        # grab the config from /etc/sysconfig/rhn/up2date
        up2date_cfg = up2date_client.config.initUp2dateConfig()

        # check that we're connected to ULN, if not, die quietly
        base_url = up2date_cfg['serverURL'].split("/")[2]
        self._out(base_url)
        p = re.compile("linux-update.*.oracle.com")
        if not p.match(base_url):
            return

        # check the global proxy settings and be sure to import them
        # again, any issues here would also get reported from the main plugin
        # so, just die quietly
        try:
            proxy_url = get_proxy_url(up2date_cfg)
            proxy_dict = {}
            if proxy_url:
                if up2date_cfg['useNoSSLForPackages']:
                    proxy_dict = {'http' : proxy_url}
                else:
                    proxy_dict = {'https' : proxy_url}
        except BadProxyConfig:
            return
       
        # we know we're registered, now get the list of subscribed channels
        try:
            svrChannels = up2date_client.rhnChannel.getChannelDetails(timeout=self.conf.timeout)
        except Exception:
            return

        # if we got this far, we are registered and have channels
        for channel in svrChannels:
            if channel['version']:
                try:
                    # if the proxy_dict is set to something other than None, we need to use it
                    if proxy_dict:
                        p = urllib.request.ProxyHandler(proxy_dict)
                        opener = urllib.request.build_opener(p)
                        urllib.request.install_opener(opener)
                    # now open the url as normal, if nothing there or an error returned, die quietly
                    url = "https://"+base_url+"/license/%s" %channel['label']
                    logger.info(urllib.request.urlopen(url).read().decode('UTF-8'))
                except:
                    pass

class BadConfig(Exception):
    pass

class BadProxyConfig(BadConfig):
    pass

def get_proxy_url(up2date_cfg):
    if not up2date_cfg['enableProxy']:
        return None

    proxy_url = ""
    if up2date_cfg['useNoSSLForPackages']:
        proxy_url = 'http://'
    else:
        proxy_url = 'https://'
    if up2date_cfg['enableProxyAuth']:
        if not up2date_cfg.has_key('proxyUser') or \
            up2date_cfg['proxyUser'] == '':
            raise BadProxyConfig
        if not up2date_cfg.has_key('proxyPassword') or \
            up2date_cfg['proxyPassword'] == '':
            raise BadProxyConfig
        proxy_url = proxy_url + up2date_cfg['proxyUser']
        proxy_url = proxy_url + ':'
        proxy_url = proxy_url + urllib.parse.quote(up2date_cfg['proxyPassword'])
        proxy_url = proxy_url + '@'

    try:
        netloc = up2date_cfg['httpProxy']
        if netloc == '':
            raise BadProxyConfig
    except KeyError:
        raise BadProxyConfig

    # Check if a protocol is supplied. We'll ignore it.
    proto_split = netloc.split('://')
    if len(proto_split) > 1:
       netloc = proto_split[1]

    return proxy_url + netloc

Youez - 2016 - github.com/yon3zu
LinuXploit