HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/up2date_client/__pycache__/config.cpython-36.pyc
3

0Q=jS;�@sBdZddlZddlZddlZddlZddlmZmZddlm	Z	m
Z
yddlmZm
Z
Wn$ek
r|ddlmZm
Z
YnXddlZejddd�Zeed	�s�eje_ejZd9d:d;d<d=d>d?d@dAdBdCdDdEddd d!gfd"�Zd#dd$gZGd%d&�d&�ZGd'd(�d(�Zd)d*�Zd+d,�Zd-d.�ZdFd0d1�ZdGd2d3�ZdHd4d5�ZdId7d8�Z dS)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�
urlunsplitzrhn-client-toolsT)Zfallback�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/systemid�4Override 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 not�BNumber 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)ZenableProxyr�
serverURLipv6Z	mirrorURL�debug�systemIdPathZversionOverride�	httpProxy�	proxyUser�
proxyPasswordZenableProxyAuthZnetworkRetriesrrr"ZtmpDirc@sleZdZdZddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�
ConfigFilez;class for handling persistent config options for the clientNcCsi|_||_|jr|j�dS)N)�dict�fileName�load)�self�filename�r,�/usr/lib/python3.6/config.py�__init__BszConfigFile.__init__cCs�|r
||_|jdkrdStj|jtj�s,dSt|jd�}d}�x�|j�D�]�}|jd�dkr^qH||j�}|spqH|ddkr�|dd�j�}qHnd}|jdd�}t	|�dkr�qH|dj�}t
|dj��}d}|jd	�}	|	dkr�|d|	�}|}d}|�rx|jd
�}
|dk�r"t|jt
j���}nVt	|
�dk�rVyt|�}Wntk
�rRYnXn"|
ddk�rjg}nd
d�|
D�}||f}||jk�r�|j|}|dk	�r�||df}|dk	�r�|d|f}||j|<qHW|j�dS)N�rr�#rr�\�=�z	[comment]�;r$r%cSsg|]}|j�r|j��qSr,)�strip)�.0�valr,r,r-�
<listcomp>�sz#ConfigFile.load.<locals>.<listcomp>���r9r9)r$r%)r(�os�access�R_OK�open�	readlines�findr5�split�lenrr�encode�locale�getpreferredencoding�int�
ValueErrorr'�close)r*r+�fZ	multiline�liner@�key�value�comment�pos�valuesZnewvalr,r,r-r)Hsd






zConfigFile.loadcCs|jdkrdStj|jtj�sTtjtjj|j�tj�sTttdtjj|j���dSx~|jj	�D]p}|j|\}}t
|�t
g�kr�|n|g}xB||gt|�D].}dt|�ks�dt|�kr�t
d||jf��q�Wq`Wtj|jdtjtjBtjBtjBtjBd�}ytj|d�tj|d�}Wn"tk
�r@tj|��YnX|jd�|jd	�|jd
�x�|jj	�D]�}|j|\}	}
|jtd||	f��t
|
�t
g�k�r�|
g}
|tk�r�ttjj|
�}
|jtd|d
jtt|
��f��|jd��qlW|j�tj|jd|j�dS)Nz%s was not found�
�
z[refusing to write config option %r to %s: a key, comment, or value contains a CR/LF newlinez.newi��wzI# Automatically generated Red Hat Update Agent config file, do not edit.
z# Format: 1.0
rz%s[comment]=%s
z%s=%s
r4)r(r:r;r<�path�dirname�print�_r'�keys�type�list�strrFr=�O_WRONLY�O_CREAT�O_TRUNC�
O_NOFOLLOW�	O_CLOEXEC�fchmod�fdopen�	ExceptionrG�writer�FileOptions�map�abspath�join�rename)r*Z_keyZ_commentZ_valueZ_valuesZ_field�fdrHrJrLrKr,r,r-�save�sL
	





"zConfigFile.savecCs
||jkS)N)r')r*�namer,r,r-�__contains__�szConfigFile.__contains__cCs||kS)Nr,)r*rjr,r,r-�has_key�szConfigFile.has_keycCs
|jj�S)N)r'rV)r*r,r,r-rV�szConfigFile.keyscCsdd�|jj�D�S)NcSsg|]}|d�qS)rr,)r6�ar,r,r-r8�sz%ConfigFile.values.<locals>.<listcomp>)r'rN)r*r,r,r-rN�szConfigFile.valuescCs|jj|�dS)N)r'�update)r*r'r,r,r-rn�szConfigFile.updatecCs||jkr|j|dSdS)Nr)r')r*rjr,r,r-�__getitem__�s
zConfigFile.__getitem__cCs0||jkr|j|}nd}|d|f|j|<dS)Nr)NN)r')r*rjrKr7r,r,r-�__setitem__�s
zConfigFile.__setitem__cCs||jkr|j|dSdS)Nrr)r')r*rjr,r,r-�info�s
zConfigFile.info)N)N)�__name__�
__module__�__qualname__�__doc__r.r)rirkrlrVrNrnrorprqr,r,r,r-r&?s

HBr&c@sveZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�ConfigNcCs.t�|_|jjt�|r$|jj|�i|_dS)N)r&�storedrn�Defaultsr)�runtime)r*r+r,r,r-r.�s
zConfig.__init__cCs ||jkrdS||jkrdSdS)NTF)ryrw)r*rjr,r,r-rks


zConfig.__contains__cCs||kS)Nr,)r*rjr,r,r-rl
szConfig.has_keycCs8t|jj��}x$|jj�D]}||kr|j|�qW|S)N)rXryrVrw�append)r*�ret�kr,r,r-rVs
zConfig.keyscCs*g}x |j�D]}|j|j|��qW|S)N)rVrzro)r*r{r|r,r,r-rNsz
Config.valuescCs.g}x$|j�D]}|j||j|�f�qW|S)N)rVrzro)r*r{r|r,r,r-�itemsszConfig.itemscCst|j��S)N)rArV)r*r,r,r-�__len__!szConfig.__len__cCs||j|<dS)N)ry)r*rjrKr,r,r-rp$szConfig.__setitem__cCs,||jkr|j|S||jkr(|j|SdS)N)ryrw)r*rjr,r,r-ro(s




zConfig.__getitem__cCs|jj|�S)N)rwrq)r*rjr,r,r-rq1szConfig.infocCs|jj�dS)N)rwri)r*r,r,r-ri4szConfig.savecCs8|jj|�x&|jj�D]}||jkr(q|j|=qWdS)N)rwr)rVry)r*r+r|r,r,r-r)7s

zConfig.loadcCs ||j|<||jkr|j|=dS)N)rwry)r*rjrKr,r,r-�setAs

z
Config.set)N)rrrsrtr.rkrlrVrNr}r~rprorqrir)rr,r,r,r-rv�s
		
rvcCs^t�}d}|d}|rZ|dd�dkr2|dd�}|jd�}tt|d��|d<dj|�}|S)zkreturns proxy string in format hostname:port
    hostname is converted to Punycode (RFC3492) if needed
    Nr#�zhttp://�:r)�initUp2dateConfigr@rYrrf)�cfg�proxyZ	proxyHost�partsr,r,r-�getProxySettingHs

r�cCs:t|�}tt|dtt|d��|d|d|df��S)z=returns url where hostname is converted to Punycode (RFC3492)rrr3��)rrrrr)Zurl�sr,r,r-�convert_url_to_punyZsr�cCs&t|t�rdd�|D�St|�gSdS)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.
    cSsg|]}t|��qSr,)r�)r6�ir,r,r-r8jsz$processServerURL.<locals>.<listcomp>N)�
isinstancerXr�)Z	serverUrlr,r,r-�processServerURL`s	
r�FcCs^t�}t|d�}t|d�}||f}||f}|r6|Sddlm}|j�}|dkrZ|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.
    rr r)�up2dateAuthZIPv6)r�r�Zup2date_clientr�ZgetPreferredInterface)�registrationr�Zipv4_urlZipv6_urlZipv4_primary_pairZipv6_primary_pairr�Zpreferred_interfacer,r,r-�getServerURLPairosr�cCst|d�dS)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-�getServerURL�s
r�cCst|d�dS)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�sr��/etc/sysconfig/rhn/up2datecCsPytWntk
r daYnXtdkrLt|�adtd<tjj�rLdtd<tS)z<This function is the right way to get at the up2date config.NF�isattyT)r��	NameErrorrv�sys�stdoutr�)Zcfg_filer,r,r-r��s

r�)r	r)r
r)rr
)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)F)F)F)r�)!rur:r�rCZrequestsZrhn.connectionsrrZrhn.i18nrrZurlparserr�ImportErrorZurllib.parse�gettextZtranslation�t�hasattrrrUrxrcr&rvr�r�r�r�r�r�r�r,r,r,r-�<module>sV
;O
'