HEX
Server: Apache
System: Linux a16-asgard6.hospedagemuolhost.com.br 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: maoristu4c3dbd03 (1436)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/rhsm/__pycache__/config.cpython-39.opt-1.pyc
a

X�Zh�=�@s�UddlZddlZddlZddlmZddlmZmZmZddl	Z	ddl
Z
ddlmZm
Z
mZmZddlmZdZdZdZd	eZd
ZdZdZd
ZdZdZd
ZdZdZdZ dZ!eeeedddddddd�Z"dededde ddddddddddd�Z#d d!dddd"d#�Z$d$d%iZ%e"e#e$e%d&�Z&e�'e(�Z)e*d'�d(d)�Z+Gd*d+�d+e�Z,Gd,d-�d-e,�Z-da.ee,e/d.<e,d'�d/d0�Z0d3d1d2�Z1dS)4�N)�SafeConfigParser)�
NoOptionError�InterpolationMissingOptionError�NoSectionError)�Dict�List�Optional�Tuple)�ugettextZRHSM_CONFIGz
/etc/rhsm/z/etc/rhsm-host/z%srhsm.confZ3128Z180zsubscription.rhsm.redhat.comZ443z
/subscriptionzcdn.redhat.com�/z
/etc/rhsm/ca/z/etc/pki/entitlementz/etc/pki/entitlement-host�0��http)�hostname�prefix�portZserver_timeoutZinsecureZproxy_hostnameZproxy_schemeZ
proxy_userZ
proxy_portZproxy_passwordZno_proxyzhttps://z%(ca_cert_dir)sredhat-uep.pemz/etc/pki/productz/etc/pki/consumer�1z/usr/share/rhsm-pluginsz/etc/rhsm/pluginconf.d)ZbaseurlZrepomd_gpg_url�ca_cert_dir�repo_ca_certZproductcertdir�entitlementcertdirZconsumercertdirZmanage_reposZfull_refresh_on_yumZreport_package_profileZ	plugindirZ
pluginconfdirZauto_enable_yum_pluginsZpackage_profile_on_transZinotifyZprogress_messagesZ240Z1440Z60)ZcertcheckintervalZautoattachintervalZsplay�disableZauto_registrationZauto_registration_interval�default_log_level�INFO)Zserver�rhsmZ	rhsmcertd�logging��returncCsFtj�t�rBtj�t�rBtt�t��rBt�dt�dt�d��dSdS)z/
    Are we running in a container or not?
    z&Container detected: found directories z and �.TF)	�os�path�isdir�HOST_CONFIG_DIR�HOST_ENT_CERT_DIR�any�walk�log�debug�r'r'�1/usr/lib64/python3.9/site-packages/rhsm/config.py�in_containerls
��r)csjeZdZdZd+eed�dd�Zd,eeeeed��fdd�
Zd-eedd	�d
d�Z	eeed��fd
d�Z
eeedd��fdd�Zd.eeed�dd�Z
eeeed�dd�Zeeefd�dd�Zeed��fdd�Zeeed�dd�Zeeeeefd��fd d!�Zeeed��fd"d#�Zeeeed$�d%d&�Zeeed�d'd(�Zeeeed�d)d*�Z�ZS)/�RhsmConfigParserz*Config file parser for rhsm configuration.N��config_filecCs ||_t�|�|�|j�dS�N)r,r�__init__�read)�selfr,�defaultsr'r'r(r.�s
zRhsmConfigParser.__init__)�
file_namesrcs.|durtt|��|j�Stt|��|�SdS)z�
        Read configuration files. When configuration files are not specified, then read self.config_file
        :param file_names: list of configuration files
        :return: number of configuration files read
        N)�superr*r/r,)r0r2��	__class__r'r(r/�szRhsmConfigParser.read�r,rc	Cs�|p|j}tj�|�}tj�|�dur0t�|�tjd|dd��d}|�|�|�	�zt�
|�j}Wntyzd}Yn0t�
|j|�t�||�Wd�n1s�0YdS)zWrites config file to storage.F�w)�mode�dir�deletei�N)r,rr�dirnamer �makedirs�tempfileZNamedTemporaryFile�write�flush�stat�st_mode�IOError�rename�name�chmod)r0r,Z
rhsm_conf_dir�for8r'r'r(�save�s



zRhsmConfigParser.save)�section�proprcs�zt�|||�WSty�tt|��||d�}t�d|�}d}|D]0}|�||�rFtt|��|||�||��d}qF|r�|�||�YS�Yn^t	t
fy�}zBzt||��WWYd}~St
y�|�Yn0WYd}~n
d}~00dS)aGet a value from rhsm config.

        :param section: config file section
        :param prop: what config property to find, the config item name
        :return: The string value of the config item.

        If config item exists, but is not set, an empty string is returned.
        Tz%\((.*?)\)sFN)r�getrr3r*�re�findall�
has_option�setrr�DEFAULTS�lower�KeyError)r0rHrIZraw_valZinterpolationsZchangedZinterpZerr4r'r(rJ�s$	zRhsmConfigParser.get)rHrD�valuercsrz|�||�|krt�Wn:tyR|�|�s:|�|�tt|��|||�Yn0|dkrn|dkrn|�|�dS)Nrr)	rJr�	Exception�has_sectionZadd_sectionr3r*rN�is_log_level_valid)r0rHrDrRr4r'r(rN�s

zRhsmConfigParser.setT)rR�
print_warningrcCsvgd�}||dgvrr|durnttd�j|d�tjd�ttd�tjd�d�|�}ttd	�j|d
�tjd�dSdS)a

        Check if provided default_log_level value is valid or not
        :param value: value of default_log_level
        :param print_warning: print warning, when provided value is not valid
        :return: True, when value is valid. Otherwise return False
        )ZCRITICALZERRORZWARNINGr�DEBUGZNOTSETTz7Invalid Log Level: {lvl}, setting to INFO for this run.)Zlvl)�filezPlease use:  subscription-manager config --logging.default_log_level=<Log Level> to set the default_log_level to a valid value.z, zValid Values: {valid_str})�	valid_strF)�print�_�format�sys�stderr�join)r0rRrVZvalidrYr'r'r(rU�s"���
z#RhsmConfigParser.is_log_level_validc	CsP|�||�}|dkrdSzt|�}Wn&ttfyJtd||f��Yn0|S)aWGet an int value from the config.

        :param section: the config section
        :param prop: the config item name
        :return:
            An int cast from the string read from.
            If config item is unset, return None.
        :raises ValueError:
            If the config value found can not be coerced into an int
        r
Nz2Section: %s, Property: %s - Integer value expected)rJ�int�
ValueError�	TypeError)r0rHrIZvalue_stringZ	value_intr'r'r(�get_intszRhsmConfigParser.get_intrcCs4g}tD]"}|dd�tt|���D�7}qt|�S)NcSsg|]\}}||f�qSr'r')�.0�keyrRr'r'r(�
<listcomp>�z-RhsmConfigParser.defaults.<locals>.<listcomp>)rO�list�items�dict�r0�resultrHr'r'r(r1s zRhsmConfigParser.defaultscs.tt|���}tD]}||vr|�|�q|Sr-)r3r*�sectionsrO�appendrkr4r'r(rm!s
zRhsmConfigParser.sectionscCs,z|�||�WdSty&YdS0dS�NTF)rJr�r0rHrIr'r'r(rM(s
zRhsmConfigParser.has_option)rHrcs�i}t�|i�D]}t||||<q|�|�r~tt|��|�}|D]8}|�||�rDt|�||����dkrD|�||�||<qDt|�	��S)Nr)
rOrJrTr3r*�options�len�striprhri)r0rHrlre�super_resultr4r'r(ri/s
$zRhsmConfigParser.itemscsNt�}t�|i�D]}|�|�q|�|�rFtt|��|�}|�|�t	|�Sr-)
rNrOrJ�addrTr3r*rq�updaterh)r0rHrirertr4r'r(rq:s

zRhsmConfigParser.options)rHrIrRrcCs|�||�|krdSdSro)�get_default)r0rHrIrRr'r'r(�
is_defaultFszRhsmConfigParser.is_defaultcCs|tvo|��t|vSr-)rOrPrpr'r'r(�has_defaultKszRhsmConfigParser.has_defaultcCs$|�||���r t||��SdSr-)ryrPrOrpr'r'r(rwNszRhsmConfigParser.get_default)NN)N)N)T)�__name__�
__module__�__qualname__�__doc__r�strr.rr/rGrJrN�boolrUr`rcrr1rmrMr	rirqrxryrw�
__classcell__r'r'r4r(r*�s "# r*cs.eZdZdZdeedd��fdd�
Z�ZS)�RhsmHostConfigParsera
    Sub-class of config parser automatically loaded when we detect that
    we're running in a container environment.

    Host config is shared with containers as /etc/rhsm-host. However the
    rhsm.conf within will still be referencing /etc/rhsm for a couple
    properties. (ca_cert_dir, repo_ca_cert)

    Instead we load config file normally, and assume to replace occurrences
    of /etc/rhsm with /etc/rhsm-host in these properties.

    A similar adjustment is necessary for /etc/pki/entitlement-host if
    present.
    Nr6cs�t��||�|�dd�}|�dd�}|�tt�}|�tt�}|�dd|�|�dd|�tj�	t
�r�|�dd�}|tks�|tdkr�t
}|�dd|�dS)Nrrrrr)r3r.rJ�replace�DEFAULT_CONFIG_DIRr!rNrr�existsr"�DEFAULT_ENT_CERT_DIR)r0r,r1rrZent_cert_dirr4r'r(r.dszRhsmHostConfigParser.__init__)NN)rzr{r|r}rr~r.r�r'r'r4r(r�Tsr��CFGcCsRztaWntydaYn0tdurNt�rDttj�td�d�an
tt	d�atS)z�
    Get an :class:`RhsmConfig` instance

    Will use the first config file defined in the following list:
    - /etc/rhsm-host/rhsm.conf if it exists (only in containers)
    - /etc/rhsm/rhsm.conf
    Nz	rhsm.confr+)
r��	NameErrorr)r�rrr_r!r*�DEFAULT_CONFIG_PATHr'r'r'r(�get_config_parser~s


r�cCst�Sr-)r�)Z
configFiler'r'r(�
initConfig�sr�)N)2r]rrZiniparserZiniparse.compatrrrrKr=�typingrrrr	Zsubscription_manager.i18nr
r[ZCONFIG_ENV_VARr�r!r�ZDEFAULT_PROXY_PORTZDEFAULT_SERVER_TIMEOUTZDEFAULT_HOSTNAMEZDEFAULT_PORTZDEFAULT_PREFIXZDEFAULT_CDN_HOSTNAMEZDEFAULT_CDN_PORTZDEFAULT_CDN_PREFIXZDEFAULT_CA_CERT_DIRr�r"ZSERVER_DEFAULTSZ
RHSM_DEFAULTSZRHSMCERTD_DEFAULTSZLOGGING_DEFAULTSrOZ	getLoggerrzr%rr)r*r�r��__annotations__r�r�r'r'r'r(�<module>s�
���
��
 I'