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/rct/__pycache__/manifest_commands.cpython-39.pyc
a

X�Zh�9�@s�ddlZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lmZd
d�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�N)�BytesIO)�ZipFile�
BadZipfile)�certificate)�
RCTCliCommand)�xstr)�InvalidCLIOptionError)�ourjson)�ugettextcCs0|}|�d�D]}||vr$||}qdSq|S)N�.�)�split)Z	json_dict�path�current�item�r�;/usr/lib64/python3.9/site-packages/rct/manifest_commands.py�	get_values
rc@sXeZdZdZdZdd�Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
dd�Zddd�ZdS)�
ZipExtractAlla�extend ZipFile with a safer extractall

    Zipfile() does not support extractall on python2.4, and the 2.6 versions
    are known to be unsafe in how they extract files. 2.6 version does not
    validate that files are within the archive root, or check that files are
    created safely.

    Contains helper methods for manipulating and reading
    the zipfile more easily in memoryNcOsJztj|g|�Ri|��Wn(tyDttd��t�d�Yn0dS)z(
        Validates the zip file
        zManifest zip is invalid.�N)r�__init__r�print�_�sys�exit)�self�args�kwargsrrrr7s
zZipExtractAll.__init__cCs,|jdur&t|�tj��}t|d�|_|jS�N�r)�	inner_zipr�read�RCTManifestCommand�
INNER_FILEr)r�outputrrr�_get_inner_zipAs
zZipExtractAll._get_inner_zipFcCs~z"t|�|��}|��}|��WnVtyxz|r:t�|���|d�}Wn&tyrttd�j	|d���Yn0Yn0|S)NTz.Unable to find file "{file_path}" in manifest.)�	file_path)
rr!�getvalue�close�KeyErrorr%�
_read_file�	Exceptionr�format)rr&Zis_innerr$�resultrrrr*Gs�zZipExtractAll._read_filecCsVg}|��}|��D]<}tj�|�\}}|tj�dd�krt|�dkr|�|�q|S)N�export�entitlementsr)r%�namelist�osrr
�join�len�append)r�resultsZin_zip�filenameZ	read_pathZ	read_filerrr�_get_entitlementsWszZipExtractAll._get_entitlementscCs"t�t�|tjtjBtjB�d�S)N�wb)r1�fdopen�open�O_RDWR�O_CREAT�O_EXCL)rrrrr�
_open_excl`szZipExtractAll._open_exclcCs&|�|�}|�|�|��|��dS�N)r>�writer!r()rZoutput_pathZarchive_pathZoutfilerrr�_write_filecs
zZipExtractAll._write_filecCsltj�|�}tj�|�}|�|�s.ttd���tj�|�}||krP|�||�ntj�|�rhttd���dS)Nz@Manifest zip attempted to extract outside of the base directory.z:Unable to trace symbolic link.  Possibly circular linkage.)	r1r�abspath�
startswithr+r�realpath�
_is_secure�islink)r�baseZnew_file�	base_path�new_pathZ
real_new_pathrrrrEhs
zZipExtractAll._is_securecCs�|�||�|��D]�}tj�|�\}}tj�||�}|�||�tj�|�sXt�|�tj�||�}|�||�tj�|�r�|r�t�|�|�	||�qdSr?)
rEr0r1rr
r2�exists�makedirs�removerA)r�location�	overwrite�	path_nameZ	directoryr6Znew_locationrrr�
extractallts

zZipExtractAll.extractall)F)F)
�__name__�
__module__�__qualname__�__doc__r rr%r*r7r>rArErPrrrrr*s


	rc@s4eZdZdZd
dd�Zdd�Zd	d
�Zddd�ZdS)r"zconsumer_export.zip�cliNFcCstj|||||d�dS)N��name�aliases�	shortdesc�primary)rr)rrWrXrYrZrrrr�szRCTManifestCommand.__init__cCstd�j|jd�S)Nz'%(prog)s {name} [OPTIONS] MANIFEST_FILE)rW)rr,rW�rrrr�
_get_usage�szRCTManifestCommand._get_usagecCs4|��}|sttd���tj�|�s0ttd���dS)Nz!You must specify a manifest file.z+The specified manifest file does not exist.)�_get_file_from_argsrrr1r�isfile)rZ
manifest_filerrr�_validate_options�s
z$RCTManifestCommand._validate_optionscCsZt|��d�}|�||�|r0tj�||j�}n|j}t|d�}|�||�t�|�dSr)rr]rPr1rr2r#rL)rrMrN�archiveZ
inner_filerrr�_extract_manifest�s
z$RCTManifestCommand._extract_manifest)rUNNF)F)rQrRrSr#rr\r_rarrrrr"�s

r"c@sFeZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dS)�CatManifestCommandcCs6tj|ddgtd�dd�|jjdddtd	�d
�dS)Nzcat-manifest�cmzPrint manifest informationTrVz--no-content�
store_trueFzskip printing Content Sets)�action�default�help�r"rr�parser�add_argumentr[rrrr�s��zCatManifestCommand.__init__rTcCszd|d}t||�|d7}|D]D}t|�dkrTtd||dt|d�f�q$td||df�q$|rvtd�dS)N�	r�z%s%s: %srz%s%sr)rr3r)r�title�items�indentZ
whitespaceZpadrrrr�_print_section�s z!CatManifestCommand._print_sectioncCs�|�tj�dd��}t�|�}g}|�td�t|d�f�|�td�t|d�f�|�td�t|d�f�|�td	�t|d
�f�|�	td�|�dS)Nr.z	meta.jsonZServerZwebAppPrefixzServer Version�versionzDate Created�createdZCreatorZ
principalNamezGeneral:�
r*r1rr2�json�loadsr4rrrp)r�zip_archive�part�data�to_printrrr�_print_general�s
z!CatManifestCommand._print_generalcCs�|�tj�dd��}t�|�}g}|�td�t|d�f�|�td�t|d�f�d}d|vrn|dd	krnd
}|�td�|f�|�td�t|d
�f�|�td�t|d�f�|�td�t|d�f�|�	td�|�dS)Nr.z
consumer.json�NamerWZUUIDZuuidZentitlement�contentAccessModeZorg_environmentzSimple Content AccesszContent Access Mode�Typez
type.labelzAPI URLZurlApizWeb URLZurlWebz	Consumer:rs)rrvrwrxryr|rrr�_print_consumer�s
z"CatManifestCommand._print_consumercCs0d}t|d�D]}|d|kr|d}q,q|S)Nzpool.productAttributesrW�value)r)rrWrxZreturn_value�attrrrr�_get_product_attribute�sz)CatManifestCommand._get_product_attributecCsJ|��}t|�dkr0|�td�dggdd�dS|D�]}|�|�}t�|�}g}|�td�t|d�f�|�td�t|d	�f�|�td
�t|d�f�|�td�t|d
�f�|�td�t|d�f�|�td�|�	d|�f�|�td�|�	d|�f�|�td�|�	d|�f�|�td�t|d�f�|�td�t|d�f�|�td�t|d�f�|�td�t|d�f�|�	d|�}|�td�|f�d }|�r�d}|�td!�|f�t
j�d"d#d$|d%�}	|�td&�|	f�|d'dd(d%}
t
j�d"d)d*|
�}|�td+�|f�zt
�|�|��d,��}Wn@t
j�yt}
z$t
�td-�j||
d.���WYd}
~
n
d}
~
00|�td/�|jf�|�td0�|dd �d1d2�|d3d4D�}|�td5�t|�d6d �d7|d3v�rd8d2�|d3d7D�}|�td9�t|�d6d �|jj�s<d:d2�|jD�}|�td;�t|�d6d�q4td<�q4dS)=NrzSubscriptions:�NonerTr{zpool.productNameZQuantityZquantityZCreatedrrz
Start DateZ	startDatezEnd DateZendDatez
Service LevelZ
support_levelzService TypeZsupport_typeZ
ArchitecturesZarchZSKUzpool.productIdZContractzpool.contractNumberZOrderzpool.orderNumberZAccountzpool.accountNumber�
virt_limitz
Virt LimitFzRequires Virt-whor.r/z%s.json�idzEntitlement FileZcertificates�serialZentitlement_certificatesz%s.pemzCertificate Filezutf-8zAUnable to read certificate file '{certificate_file}': {exception})Zcertificate_file�	exceptionzCertificate Versionz
Subscription:cSs g|]}t|d�|df�qS�Z	productIdZproductName��int��.0�pprrr�
<listcomp>�z6CatManifestCommand._print_products.<locals>.<listcomp>ZpoolZprovidedProductszProvided Products:rlZderivedProvidedProductscSs g|]}t|d�|df�qSr�r�r�rrrr� s�zDerived Products:cSsg|]}|jg�qSr)�url)r�rrrrr�(r�z
Content Sets:r)r7r3rprr*rtrur4rr�r1rr2rZcreate_from_pem�decodeZCertificateExceptionr,rq�sorted�optionsZ
no_contentZcontentr)rrvr/Zent_filerwrxryr�Zrequire_virt_whoZentitlement_filer�Z	cert_fileZcertZcerrr�_print_products�sh


��
�
z"CatManifestCommand._print_productscCsLt|��d�}td�ttd��td�|�|�|�|�|�|�dS)�:
        Does the work that this command intends.
        rz.
+-------------------------------------------+z		Manifestz.+-------------------------------------------+
N)rr]rrrzr~r�)rZtemprrr�_do_command-s

zCatManifestCommand._do_commandN)rT)
rQrRrSrrprzr~r�r�r�rrrrrb�s

	Erbc@s$eZdZdd�Zdd�Zdd�ZdS)�DumpManifestCommandcCsPtj|ddgtd�dd�|jjddtd�d	�|jjd
ddd
dtd�d�dS)Nz
dump-manifestZdmzDump the contents of a manifestTrVz
--destination�destinationz$directory to extract the manifest to)�destrgz-fz--forcerd�overwrite_filesFzoverwrite files which may exist)rer�rfrgrhr[rrrr=s(���zDumpManifestCommand.__init__c
Cs�z|�||�Wnpty�}zX|jtjkrDttd�j|jd��n&ttd��t|j�|jrjt|j�WYd}~dSd}~00dS)Nz?File "{filename}" exists. Use -f to force overwriting the file.)r6zManifest could not be written:FT)	ra�EnvironmentError�errnoZEEXISTrrr,r6�strerror)rr�rN�errr�_extractTs��

zDumpManifestCommand._extractcCsZ|jjr6|�|jj|jj�rVttd�j|jjd��n |�t��|jj�rVttd��dS)r�z;The manifest has been dumped to the {destination} directory)r�z5The manifest has been dumped to the current directoryN)	r�r�r�r�rrr,r1�getcwdr[rrrr�is��zDumpManifestCommand._do_commandN)rQrRrSrr�r�rrrrr�<sr�)r�r1r�ior�zipfilerrZrhsmrZrct.commandsrZrct.printingrZsubscription_manager.clirr	rtZsubscription_manager.i18nr
rrrr"rbr�rrrr�<module>s Y#