HEX
Server: LiteSpeed
System: Linux us-phx-web629.main-hosting.eu 5.14.0-503.23.2.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 12 05:52:18 EST 2025 x86_64
User: u756937133 (756937133)
PHP: 8.2.30
Disabled: passthru,chgrp
Upload Files
File: //lib/python3.9/site-packages/S3/__pycache__/Config.cpython-39.pyc
a

�9pe�t�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZddl
mZzddlZddlZWn2ey�ej�d�ej��e�e�Yn0zddlZWney�ddlmZYn0z ddlmZmZmZmZmZ Wn0e�y4ddlmZmZmZmZmZ Yn0ddl!m"Z"dd	l#m#Z#dd
l$m%Z%m&Z&m'Z'm(Z(m)Z)ze*Wne+�y�e,Z*Yn0dd�Z-d
d�Z.dd�Z/Gdd�de0�Z1Gdd�de0�ZGdd�de0�Z2dS)�)�absolute_importN)�debug�warning�)�	EX_OSFILEa:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ImportError trying to import dateutil.parser and dateutil.tz.
Please install the python dateutil module:
$ sudo apt-get install python-dateutil
  or
$ sudo yum install python-dateutil
  or
$ pip install python-dateutil
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
)�
NoOptionError�NoSectionError�MissingSectionHeaderError�ParsingError�ConfigParser)�Progress)�
SortedDict)�s3_quote�getTreeFromXml�getDictFromTree�base_unicodise�dateRFC822toPythoncCs8t|�tkr|��dvSt|�tkr0|dkr0dSdSdS)zsCheck to see if a string is true, yes, on, or 1

    value may be a str, or unicode.

    Return True if it is
    )�trueZyesZon�1TFN��type�unicode�lower�bool��value�r�-/usr/lib/python3.9/site-packages/S3/Config.py�is_bool_trueMs
rcCs8t|�tkr|��dvSt|�tkr0|dkr0dSdSdS)ztCheck to see if a string is false, no, off, or 0

    value may be a str, or unicode.

    Return True if it is
    )Zfalse�noZoff�0FTNrrrrr�
is_bool_false\s
r!cCst|�pt|�S)z)Check a string value to see if it is bool)rr!rrrr�is_boolksr"c@s>eZdZdZgZiZdZdZdZdZ	dZ
dZdZdZ
dZdZdZejZej��ZejZdZdZd	Zd	Zd	Ze dd
�Z!d	Z"d	Z#dZ$d	Z%d	Z&dZ'd	Z(d	Z)dZ*dZ+dZ,gZ-gZ.dZ/d
Z0d	Z1d	Z2dZ3dZ4gd�Z5d	Z6d	Z7d	Z8d	Z9dZ:dZ;ded<d	Z<dZ=dZ>dZ?dZ@dZAdZBdZCdZDdZEdZFdZGdZHdZIdZJdZKdZLdZMdZNdZOddgZPgZQgZRiZSiZTeU�V��p\dZWdZXdZYd	ZZdZ[d	Z\dZ]d	Z^d	Z_dZ`dZadZbdZcgZdgZedZfdZggZhdZidZjdZkd	Zld	Zmd Znd	Zod	ZpdZqdZrd	Zsd	Ztd	Zud!Zvd	ZwdZxd"Zyd	Zzd"Z{d5d#d$�Z|d6d%d&�Z}d'd(�Z~d)d*�Zd+d,�Z�d-d.�Z�d/d0�Z�d1d2�Z�d3d4�Z�dS)7�ConfigN�Tzs3.amazonaws.comz%(bucket)s.s3.amazonaws.comzsdb.amazonaws.comzcloudfront.amazonaws.comiF)Zignore_caserZStandardi8)	�uname�uid�gname�gidZatime�mtime�ctime�mode�md5���z@[sync] Remove remote S3 objects when local file has been deleted�delete_removedz}%(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sz}%(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sZUSzbinary/octet-stream�ii'�sizer,�UTF-8Znormali,z
index.htmlz8http://%(bucket)s.s3-website-%(location)s.amazonaws.com/r�d�cCs|jdurt�|�|_|jS�N)�	_instance�object�__new__)�self�
configfile�
access_key�
secret_key�access_tokenrrrr7s
zConfig.__new__cCs0|�r,z|�|�Wn.tyBdtjvs6dtjvr>|��Yn0|rX|rX||_||_|rh||_d|_t	|j�dkr�t�
d�p�t�
d�}t�
d�p�t�
d�}t�
d	�p�t�
d
�}|r�|s�td��t|�|_t|�|_|r�d|_t|�|_n|�
�|j�r|jdk�rtd
�|j�r,|jdk�r,td��dS)N�AWS_CREDENTIAL_FILE�AWS_PROFILEFrZAWS_ACCESS_KEYZAWS_ACCESS_KEY_IDZAWS_SECRET_KEYZAWS_SECRET_ACCESS_KEYZAWS_SESSION_TOKENZAWS_SECURITY_TOKENzRAWS_ACCESS_KEY environment variable is used but AWS_SECRET_KEY variable is missingTz�Cannot have server_side_encryption (S3 SSE) and KMS_key set (S3 KMS). KMS encryption will be used. Please set server_side_encryption to FalsezFKMS encryption requires signature v4. Please set signature_v2 to False)�read_config_file�IOError�os�environ�aws_credential_filer:r;r<�_access_token_refresh�len�getenv�
ValueErrorr�role_config�kms_key�server_side_encryptionr�signature_v2�	Exception)r8r9r:r;r<Zenv_access_keyZenv_secret_keyZenv_access_tokenrrr�__init__
s>�

zConfig.__init__cCst�zVtj�d�}|�r�dtt���}dd||d�}tj�d�}|r�t|��}|��}Wd�n1sj0Yd|d	<||d
<d�dd
�|��D��}d}tj�d�dkr�tj�d�}	|	s�|j	}	d|	}t
j|dd�}
|
�dd|�|
�
�}|��}|jdk�r�t|�dk�r�t|�}
t|
�}|
jdk�r@|dd}n(|
jdk�rZ|dd}ntd|
j��t��d|d �t��d!|d"�t��d#|d$�tt|d%��}|tjd&d'�|_tj�tj���|_nt��nxt
j d(dd�}
i}zHd)d*i}|
jd+d,|d-�|
�
�}|��}|jdk�r6t|�}d.|i}Wnt!�yT|
�"�Yn0|
jd/d0|d-�|
�
�}|��}|jdk�rRt|�dk�rR|
jd/d1|�#d2�|d-�|
�
�}|jdk�rLt|���}t$�%|�}t��dt|d ��t��d!t|d"��t��d#t|d3��tt|d%��}|tjd&d'�|_tt|d4��|_nt�nt�Wnt!�yn�Yn0dS)5zL
        Get credentials from IAM authentication and STS AssumeRole
        ZAWS_ROLE_ARNzrole-session-%sZ
AssumeRolez
2011-06-15)�ActionZVersionZRoleArnZRoleSessionNameZAWS_WEB_IDENTITY_TOKEN_FILENZAssumeRoleWithWebIdentityrNZWebIdentityToken�&cSs$g|]\}}d|t|dd�f�qS)z%s=%sT)Zunicode_output)r)�.0�k�vrrr�
<listcomp>Is�z&Config.role_config.<locals>.<listcomp>zsts.amazonaws.comZAWS_STS_REGIONAL_ENDPOINTSZregionalZ
AWS_REGIONzsts.%s.amazonaws.com�)�host�timeoutZPOSTz/?��rZAssumeRoleResponseZAssumeRoleResultZCredentialsZ!AssumeRoleWithWebIdentityResponseZAssumeRoleWithWebIdentityResultz.Unexpected XML message from STS server: <%s />r:ZAccessKeyIdr;ZSecretAccessKeyr<ZSessionTokenZ
Expirationr/)Zminutesz169.254.169.254z$X-aws-ec2-metadata-token-ttl-secondsZ60ZPUTz/latest/api/token)ZheaderszX-aws-ec2-metadata-tokenZGETz+/latest/meta-data/iam/security-credentials/z-/latest/meta-data/iam/security-credentials/%szutf-8�TokenZLastUpdated)&rArB�get�int�time�open�read�join�items�bucket_location�httplibZHTTPSConnectionZrequestZgetresponse�statusrErr�tagr@r#�
update_optionrr�datetimeZ	timedelta�_access_token_expiration�now�dateutil�tz�tzutc�_access_token_last_updateZHTTPConnectionrL�close�decode�json�loads)r8Zrole_arnZrole_session_name�paramsZweb_identity_token_file�fZweb_identity_tokenZencoded_paramsZsts_endpointZregionZconnZrespZresp_contentZtreeZresult_dictZcredsZ
expirationZ	imds_authZimds_ttlZ
imds_token�filesrrrrH5s��
&
����
zConfig.role_configcCsh|jrdtj�tj���}|jr<||jkr<|jr<|j|kr<dSz|��Wnt	ybt
d�Yn0dS)NzCould not refresh role)rDrergrhrirjrfrkrHrLr)r8rgrrr�role_refresh�s���zConfig.role_refreshc
s"�z�tj�d��tj�d�}|r6tj�|�r6t|��ntj���sHWdSt��td��t	j
�dt|dd�d��}|��}Wd�n1s�0YzDz��
t	�|��Wn*ty�d|}��
t	�|��Yn0Wn:t�y}z td	�t|�f��WYd}~n
d}~00ttj�d
d��}td|�d��fdd�	}||dd�}|�rlt��dt|��||dd�}|�r�t��dt|��||ddd�}	|	�r�t��dt|	��Wndt�y�}
ztd|
j��WYd}
~
n:d}
~
0t�y}
ztd|��WYd}
~
n
d}
~
00dS)Nz~/.aws/credentialsr=zReading AWS credentials from %s�r�encodingr1�ruz
[default]
z*Error reading aws_credential_file (%s): %sr>�defaultzUsing AWS profile '%s'Tc
s�d}z��||�}Wn�ty�}zn|r:td|j|j��|r�z"|}d}��||�}td|�Wn$ty�}zWYd}~n
d}~00WYd}~n
d}~00|r�td||��|S)NzLCouldn't find key '%s' for the AWS Profile '%s' in the credentials file '%s'rwz�Legacy configuration key '%s' used, please use the standardized config format as described here: https://aws.amazon.com/blogs/security/a-new-and-standardized-way-to-manage-credentials-in-the-aws-sdks/zWFound the configuration option '%s' for the AWS Profile '%s' in the credentials file %s)rYrr�option�sectionr)�profile�keyZ
legacy_keyZ
print_warning�result�e�rC�configrr�get_key�s0
��,�z+Config.aws_credential_file.<locals>.get_keyZaws_access_key_idZAWSAccessKeyIdr:Zaws_secret_access_keyZAWSSecretKeyr;Zaws_session_tokenFr<z&Errno %d accessing credentials file %sz;Couldn't find AWS Profile '%s' in the credentials file '%s')T)rA�path�
expanduserrBrY�isfiler�PyConfigParserr�ior\�getattrr]Zreadfp�StringIOr	r
rG�strr#rdr@r�errnor)r8Zcredential_file_from_env�fpZ
config_string�excrzr�Zprofile_access_keyZprofile_secret_keyZprofile_access_tokenr}rr~rrC�sx
�

�&
�� ��������zConfig.aws_credential_filecCsTg}t|�D]B}ttt|��}|�d�s|td�td�td�fvrDq|�|�q|S)N�_�string�*T)�dirrr�r#�
startswith�append)r8ZretvalrxZoption_typerrr�option_lists
��zConfig.option_listcCs�t|�}|��D]*}|�|�}|dur.|��}|�||�q|�d�rX|�d|�d��|�d�r�|�d��d�D]&}|�dd�\}}|��|j|��<qr|j�|�dS)N�
acl_public�add_headers�,�:r)	rr�rY�striprd�split�
extra_headers�
_parsed_filesr�)r8r9ZcprxZ_optionr{rrrrr?&s


zConfig.read_config_filecCst|��d|�dS)Nrw)�ConfigDumper�dump�r8�streamrrr�dump_config:szConfig.dump_configcCs>|durdSt|��d�r4|�|t�|dd���S|dkr�zt|�}Wnbty�z0ztj|}Wnt	y�tj
|}Yn0Wnty�td|��Yn0Yn0�n~|dk�rB|�d�s�|�d�r�d}n|�d	�s�|�d
�r�d}nd}z(|�rt|dd
��|>�pt|�}Wn$t
�y>td||f��Yn0n�ttt|��td�u�sttt|�du�r�t|��r�t|��r�d}n t|��r�d}ntd||f��n�ttt|��td�u�r�zt|�}Wn$t�y�td||f��Yn0n<|dv�r.|�d��r|dd�}n|�d��r.|dd�}tt||�dS)N�$r�	verbosityz)Config: verbosity level '%s' is not valid�	limitraterQ�K�
�m�M�rr-zFConfig: value of option %s must have suffix m, k, or nothing, not '%s'TFz8Config: value of option '%s' must be Yes or No, not '%s'r�z9Config: value of option '%s' must be an integer, not '%s')�	host_base�host_bucket�cloudfront_hostzhttp://�zhttps://�)rr�rdrArFrZrG�logging�_levelNames�AttributeErrorZ_nameToLevel�KeyError�endswithrLrr�r#r"rr!�setattr)r8rxr�shiftrrrrd=s\
(��


zConfig.update_option)NNNN)NNNN)��__name__�
__module__�__qualname__r5r�Z_docr:r;r<rDrfrkr�r�rIZ
simpledb_hostr�r�ZWARNINGr��sys�stdout�isattyZprogress_meterrZ
ProgressCRZprogress_classZ
send_chunkZ
recv_chunkZlist_md5Zlong_listingZhuman_readable_sizesr
r��forcerJ�enableZget_continueZput_continueZ	upload_idZ
skip_existing�	recursiveZrestore_daysZrestore_priorityr�Z
acl_grantsZacl_revokesZ
proxy_hostZ
proxy_portZencrypt�dry_runZadd_encoding_extsZpreserve_attrsZpreserve_attrs_listZ	keep_dirsr.Zdelete_afterZdelete_after_fetchZ
max_delete�limitZ
delay_updates�gpg_passphraseZgpg_commandZgpg_encryptZgpg_decryptZ	use_httpsZ
ca_certs_fileZssl_client_key_fileZssl_client_cert_fileZcheck_ssl_certificateZcheck_ssl_hostnamer`Zdefault_mime_typeZguess_mime_typeZuse_mime_magicZ	mime_typeZenable_multipartZmultipart_chunk_size_mbZmultipart_copy_chunk_size_mbZmultipart_max_chunksZsync_checksZexcludeZincludeZ
debug_excludeZ
debug_include�locale�getpreferredencodingruZurlencoding_modeZlog_target_prefixZreduced_redundancyZ
storage_class�follow_symlinksZsocket_timeoutZinvalidate_on_cfZinvalidate_default_index_on_cfZ#invalidate_default_index_root_on_cfZ
website_indexZ
website_errorZwebsite_endpointZadditional_destinationsZ
files_fromZ
cache_filer�Zremove_headersZexpiry_daysZexpiry_dateZ
expiry_prefixZskip_destination_validationrKr�Zrequester_paysZ
stop_on_errorZcontent_dispositionZcontent_typeZstatsZuse_http_expectZsignurl_use_httpsZthrottle_maxZpublic_url_use_httpsZconnection_poolingZconnection_max_ageZlist_allow_unorderedZmax_retriesr7rMrHrsrCr�r?r�rdrrrrr#ps�



+tar#c@s>eZdZgfdd�Zgfdd�Zdd�Zdd�Zdd
d�Zd	S)
rcCsi|_|�||�dSr4)�cfg�
parse_file)r8�file�sectionsrrrrM~szConfigParser.__init__cCs�td|�t|�tg�kr"|g}d}t�d�}t�d�}t�d�}t�d�}t�d�}tj|d|�d	d
�d���(}	|	D�]}
|�|
�sx|�|
�r�qx|�|
�}|r�|��d}||vp�t	|�dk}qx|�|
�}
|
�rz|�rz|
�
�}|�|d
��r|d
dd�|d
<|�|d|d
�|ddv�r\d|d
dd�t	|d
�d|d
dd�f}n|d
}td|d|f�qxtd||
f�qxWd�n1�s�0YdS)NzConfigParser: Reading file '%s'Tz^\s*#.*z^\s*$z
^\[([^\]]+)\]z$^\s*(?P<key>\w+)\s*=\s*(?P<value>.*)z^"(.*)"\s*$rtrur1rvrrrr-r{)r:r;r�z%s...%d_chars...%srT�zConfigParser: %s->%sz!Ignoring invalid line in '%s': %s)
rr�re�compiler�r\rY�match�groupsrE�	groupdict�__setitem__r)r8r�r�Zin_our_sectionZ	r_commentZr_emptyZ	r_sectionZr_dataZr_quotesr��lineZ
is_sectionryZis_data�dataZprint_valuerrrr��s<







4zConfigParser.parse_filecCs
|j|Sr4�r�)r8�namerrr�__getitem__�szConfigParser.__getitem__cCs||j|<dSr4r�)r8r�rrrrr��szConfigParser.__setitem__NcCs||jvr|j|S|Sr4r�)r8r�rwrrrrY�s

zConfigParser.get)N)r�r�r�rMr�r�r�rYrrrrr}s
!rc@seZdZdd�Zdd�ZdS)r�cCs
||_dSr4)r�r�rrrrM�szConfigDumper.__init__c	Cs�|j�d|�|��D]x}t||�}|dkr|t|t�r|z0ztj|}Wntydtj	|}Yn0Wnt
yzYn0|j�d||f�qdS)Nz[%s]
r�z%s = %s
)r��writer�r��
isinstancerZr�r�r�Z_levelToNamer�)r8ryrrxrrrrr��s

zConfigDumper.dumpN)r�r�r�rMr�rrrrr��sr�)3Z
__future__rr�rer�r�rAr�r�rnr[rrZ	ExitCodesrZdateutil.parserrhZdateutil.tz�ImportError�stderrr��flush�exitraZhttp.clientZclientZconfigparserrrr	r
rr�r$rr
Z	BaseUtilsrrrrrr�	NameErrorr�rr!r"r6r#r�rrrr�<module>
sV
 "
1