<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
mi	5                 @   sB  d Z ddlZddlZddlZddlZddlmZmZ ddlm	Z	m
Z
 yddlmZmZ W n$ ek
r|   ddlmZmZ Y nX ddlZejdddZeed	seje_ejZd9d:d;d<d=d>d?d@dAdBdCdDdEddd d!gfd"Zd#dd$gZG d%d& d&ZG d'd( d(Zd)d* Zd+d, Zd-d. ZdFd0d1ZdGd2d3ZdHd4d5ZdId7d8Z dS )Jzj
This module includes the Config and Up2date Config classes use by the
up2date agent to hold config info.
    N)idn_ascii_to_punyidn_puny_to_unicode)ustrsstr)urlsplit
urlunsplitzrhn-client-toolsT)ZfallbackugettextUse a HTTP ProxyRemote server URL)https://xmlrpc.cln.cloudlinux.com/XMLRPC/&Remote server URL for access over IPv6.https://ipv6.xmlrpc.cln.cloudlinux.com/XMLRPC/Mirror list URL>https://repo.cloudlinux.com/cloudlinux/mirrorlists/cln-mirrors#Whether or not debugging is enabledLocation of system id/etc/sysconfig/rhn/systemid4Override the automatically determined system version ;HTTP proxy in host:port format, e.g. squid.example.com:3128'The username for an authenticated proxy.The password to use for an authenticated proxy$To use an authenticated proxy or notBNumber of attempts to make at network connections before giving up   )The CA cert used to verify the ssl server'/usr/share/rhn/CLN-ORG-TRUSTED-SSL-CERTzDConfig options that can not be overwritten by a config update action	sslCACert	serverURLdisallowConfChanges)ZenableProxyr   serverURLipv6Z	mirrorURLdebugsystemIdPathZversionOverride	httpProxy	proxyUserproxyPasswordZenableProxyAuthZnetworkRetriesr   r   r"   ZtmpDirc               @   sl   e Zd ZdZdddZdddZdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd ZdS )
ConfigFilez;class for handling persistent config options for the clientNc             C   s   i | _ || _| jr| j  d S )N)dictfileNameload)selffilename r,   /usr/lib/python3.6/config.py__init__B   s    zConfigFile.__init__c             C   s  |r
|| _ | j d krd S tj| j tjs,d S t| j d}d}x|j D ]}|jddkr^qH||j  }|spqH|d dkr|d d j }qHnd}|jdd}t	|dkrqH|d j }t
|d j }d }|jd	}	|	dkr|d |	 }|}d }|rx|jd
}
|dkr"t|jtj }nVt	|
dkrVyt|}W n tk
rR   Y nX n"|
d dkrjg }ndd |
D }||f}|| jkr| j| }|d k	r||d f}|d k	r|d |f}|| j|< qHW |j  d S )Nrr   #r   r   \=   z	[comment];r$   r%   c             S   s   g | ]}|j  r|j  qS r,   )strip).0valr,   r,   r-   
<listcomp>   s    z#ConfigFile.load.<locals>.<listcomp>r9   r9   )r$   r%   )r(   osaccessR_OKopen	readlinesfindr5   splitlenr   r   encodelocalegetpreferredencodingint
ValueErrorr'   close)r*   r+   fZ	multilineliner@   keyvaluecommentposvaluesZnewvalr,   r,   r-   r)   H   sd    






zConfigFile.loadc          	   C   sJ  | j d krd S tj| j tjsTtjtjj| j tjsTttdtjj| j   d S t| j d d}tj	| j d t
dd |jd |jd |jd x| jj D ]}| j| \}}|jtd	||f  t|tg kr|g}|tkrttjj|}|jtd
|djtt|f  |jd qW |j  tj| j d | j  d S )Nz%s was not foundz.newwZ0644   zI# Automatically generated Red Hat Update Agent config file, do not edit.
z# Format: 1.0
r   z%s[comment]=%s
z%s=%s
r4   
)r(   r:   r;   r<   pathdirnameprint_r=   chmodrE   writer'   keysr   typeFileOptionsmapabspathjoinstrrG   rename)r*   rH   rJ   rL   rK   r,   r,   r-   save   s,    
	


"zConfigFile.savec             C   s
   || j kS )N)r'   )r*   namer,   r,   r-   __contains__   s    zConfigFile.__contains__c             C   s   || kS )Nr,   )r*   ra   r,   r,   r-   has_key   s    zConfigFile.has_keyc             C   s
   | j j S )N)r'   rX   )r*   r,   r,   r-   rX      s    zConfigFile.keysc             C   s   dd | j j D S )Nc             S   s   g | ]}|d  qS )r   r,   )r6   ar,   r,   r-   r8      s    z%ConfigFile.values.<locals>.<listcomp>)r'   rN   )r*   r,   r,   r-   rN      s    zConfigFile.valuesc             C   s   | j j| d S )N)r'   update)r*   r'   r,   r,   r-   re      s    zConfigFile.updatec             C   s   || j kr| j | d S d S )Nr   )r'   )r*   ra   r,   r,   r-   __getitem__   s    
zConfigFile.__getitem__c             C   s0   || j kr| j | }nd}|d |f| j |< d S )Nr   )NN)r'   )r*   ra   rK   r7   r,   r,   r-   __setitem__   s    
zConfigFile.__setitem__c             C   s   || j kr| j | d S dS )Nr   r   )r'   )r*   ra   r,   r,   r-   info   s    
zConfigFile.info)N)N)__name__
__module____qualname____doc__r.   r)   r`   rb   rc   rX   rN   re   rf   rg   rh   r,   r,   r,   r-   r&   ?   s   

H#r&   c               @   sv   e Zd ZdddZdd Zdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd ZdS )ConfigNc             C   s.   t  | _| jjt |r$| jj| i | _d S )N)r&   storedre   Defaultsr)   runtime)r*   r+   r,   r,   r-   r.      s
    zConfig.__init__c             C   s    || j krdS || jkrdS dS )NTF)rp   rn   )r*   ra   r,   r,   r-   rb      s
    

zConfig.__contains__c             C   s   || kS )Nr,   )r*   ra   r,   r,   r-   rc      s    zConfig.has_keyc             C   s8   t | jj }x$| jj D ]}||kr|j| qW |S )N)listrp   rX   rn   append)r*   retkr,   r,   r-   rX      s
    zConfig.keysc             C   s*   g }x | j  D ]}|j| j| qW |S )N)rX   rr   rf   )r*   rs   rt   r,   r,   r-   rN      s    zConfig.valuesc             C   s.   g }x$| j  D ]}|j|| j|f qW |S )N)rX   rr   rf   )r*   rs   rt   r,   r,   r-   items   s    zConfig.itemsc             C   s   t | j S )N)rA   rX   )r*   r,   r,   r-   __len__  s    zConfig.__len__c             C   s   || j |< d S )N)rp   )r*   ra   rK   r,   r,   r-   rg     s    zConfig.__setitem__c             C   s,   || j kr| j | S || jkr(| j| S d S )N)rp   rn   )r*   ra   r,   r,   r-   rf   	  s
    



zConfig.__getitem__c             C   s   | j j|S )N)rn   rh   )r*   ra   r,   r,   r-   rh     s    zConfig.infoc             C   s   | j j  d S )N)rn   r`   )r*   r,   r,   r-   r`     s    zConfig.savec             C   s8   | j j| x&| j j D ]}|| jkr(q| j|= qW d S )N)rn   r)   rX   rp   )r*   r+   rt   r,   r,   r-   r)     s
    
zConfig.loadc             C   s    || j |< || jkr| j|= d S )N)rn   rp   )r*   ra   rK   r,   r,   r-   set"  s    

z
Config.set)N)ri   rj   rk   r.   rb   rc   rX   rN   ru   rv   rg   rf   rh   r`   r)   rw   r,   r,   r,   r-   rm      s   
		
rm   c              C   s^   t  } d}| d }|rZ|dd dkr2|dd }|jd}tt|d |d< dj|}|S )zkreturns proxy string in format hostname:port
    hostname is converted to Punycode (RFC3492) if needed
    Nr#      zhttp://:r   )initUp2dateConfigr@   r^   r   r]   )cfgproxyZ	proxyHostpartsr,   r,   r-   getProxySetting)  s    

r~   c             C   s:   t | }tt|d tt|d |d |d |d fS )z=returns url where hostname is converted to Punycode (RFC3492)r   r   r3         )r   r   r   r   r   )Zurlsr,   r,   r-   convert_url_to_puny;  s    r   c             C   s&   t | trdd | D S t| gS dS )z
    Internal function to process server URL to Punycode format.

    Processes both single URLs and lists of URLs.

    :param serverUrl: URL or list of URLs to process.
    :return: List of processed URLs in Punycode format.
    c             S   s   g | ]}t |qS r,   )r   )r6   ir,   r,   r-   r8   K  s    z$processServerURL.<locals>.<listcomp>N)
isinstancerq   r   )Z	serverUrlr,   r,   r-   processServerURLA  s    	
r   Fc             C   s^   t  }t|d }t|d }||f}||f}| r6|S ddlm} |j }|dkrZ|rZ|S |S )a  
    Return a pair of server URLs (primary and fallback) based on the preferred interface.

    :param registration: If True, it indicates that the URLs are being fetched for registration purposes.
    If that is the case, the function will always use IPv4 URLs with IPv6 as fallback,
    regardless of the preferred_interface setting.
    Assumed false by default, expected to be specified explicitly when needed.

    :return: Pair of server URL configs, first is the primary, second is the fallback.
    r   r    r   )up2dateAuthZIPv6)rz   r   Zup2date_clientr   ZgetPreferredInterface)registrationr{   Zipv4_urlZipv6_urlZipv4_primary_pairZipv6_primary_pairr   Zpreferred_interfacer,   r,   r-   getServerURLPairP  s    r   c             C   s   t | dd S )az  
    Return the primary server URL from config based on preferred_interface.

    If preferred_interface=IPv6 in system_id, returns serverURLipv6 if available.
    Otherwise returns normal serverURL.
    Note: the config may have one value or a list of values, but this function always returns a list.

    :return: List of server URLs with hostnames converted to Punycode.
    )r   r   )r   )r   r,   r,   r-   getServerURLw  s    
r   c             C   s   t | dd S )z
    Determine the fallback server URL from system_id.

    The fallback server URL is the one that is *not* set as preferred_interface.
    If preferred_interface is IPv6, it returns serverURL (i.e. IPv4 host), otherwise serverURLipv6.
    )r   r   )r   )r   r,   r,   r-   getFallbackServerURL  s    r   /etc/sysconfig/rhn/up2datec             C   sP   yt  W n tk
r    da Y nX t dkrLt| a dt d< tjj rLdt d< t S )z<This function is the right way to get at the up2date config.NFisattyT)r{   	NameErrorrm   sysstdoutr   )Zcfg_filer,   r,   r-   rz     s    

rz   )r	   r   )r
   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )F)F)F)r   )!rl   r:   r   rC   ZrequestsZrhn.connectionsr   r   Zrhn.i18nr   r   Zurlparser   r   ImportErrorZurllib.parsegettextZtranslationthasattrr   rU   ro   rZ   r&   rm   r~   r   r   r   r   r   rz   r,   r,   r,   r-   <module>   sV   
 O
'


