HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/s3.cpython-310.pyc
o

�N�g�"�@s�dZddlZddlZddlmmZddlZ	ddl
Z	ddlZ	ddlm
mZddlmZzddlZdZWneyAdZYnwe�e�Z																			dd	d
�ZdS)z6
Connection library for Amazon S3

:depends: requests
�N)�CommandExecutionErrorTF�GET��@c%Cs$tst�d�|si}|si}|sd}|r|r|}n|�d|��}|r,|r,|�d|	��}	|s3tjjj}|s:tjjj}|durJ|dvrJd|d<||d	<|sRtjj��}d
}d}d}|dkrg|rgtjjj	|dd
�}|	durmd
}	t
j�|	�}	|s�d�
|r{dnd||	�}tjjj||||d|	��||d�||d|||d�\}}t�d|�t�d�t�d|d�|s�d}zI|dkr�|r�tjj�|d�}|��}tj|||||
ddd�}n |dkr�|r�|
s�tj|||||
ddd�}ntj|||||
dd�}W|dur�|��n|du�r|��wwd}d}|jdk�rX|j�pd}t�d |�zt�t�|��}|d!}|d"}Wn(ttjf�yW}zt�d#t|�j|�d$|j��}|}WYd}~nd}~wwt�d%|j�|dk�r�|jd&k�r�|�rwt d'�
||	||���t d(|�d)|�d*|����|�r�t�d+||	�dSt�d,|�dS|d-k�r�t!|j��"d.��s�|	�r�t d/�
|	|||���t d0|�d)|�d*|����|	�r�t�d1|	|�dSt�d2|�dS|�r%|dk�r%|jd&k�s�|jdk�r�t d3|�d*|����t�d4|�tjj�|d5��}|j#|d6�D]} |�$| ��qWd�n	1�swYd7|��S|jd&k�s1|jdk�r;t d8|�d*|����|
�rA|jS|j�rft�|j�}!g}"|!D]}#|"�%t�|#���qO|du�rd|"|fS|"S|jtj&j'k�rpdSd9gi}"|�r�t(|j)�|"d9<|"S|j)D]}$|"d9�%|$�*���q�|"S):a"
    Perform a query against an S3-like API. This function requires that a
    secret key and the id for that key are passed in. For instance:

        s3.keyid: GKTADJGHEIQSXMKKRBJ08H
        s3.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    If keyid or key is not specified, an attempt to fetch them from EC2 IAM
    metadata service will be made.

    A service_url may also be specified in the configuration:

        s3.service_url: s3.amazonaws.com

    If a service_url is not specified, the default is s3.amazonaws.com. This
    may appear in various documentation as an "endpoint". A comprehensive list
    for Amazon S3 may be found at::

        http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

    The service_url will form the basis for the final endpoint that is used to
    query the service.

    Path style can be enabled:

        s3.path_style: True

    This can be useful if you need to use salt with a proxy for an s3 compatible storage

    You can use either https protocol or http protocol:

        s3.https_enable: True

    SSL verification may also be turned off in the configuration:

        s3.verify_ssl: False

    This is required if using S3 bucket names that contain a period, as
    these will not match Amazon's S3 wildcard certificates. Certificate
    verification is enabled by default.

    A region may be specified:

        s3.location: eu-central-1

    If region is not specified, an attempt to fetch the region from EC2 IAM
    metadata service will be made. Failing that, default is us-east-1
    z6There was an error: requests is required for s3 accesszs3.amazonaws.com�.�/N)�PUT�POSTzaws:kmszx-amz-server-side-encryptionz+x-amz-server-side-encryption-aws-kms-key-idrr�sha256)Zformz
{}://{}/{}�https�http)�id�keyZs3)	�dataZuriZ	prov_dict�role_arn�location�product�
requesturl�headers�payload_hashzS3 Request: %szS3 Headers::z    Authorization: %sZ
Authorization�rbTi,)rr�verify�stream�timeoutr)rrrri�z
Unknown errorz    Response content: %sZCode�Messagez'Failed to parse s3 err response. %s: %szhttp-zS3 Response Status Code: %s��z&Failed to upload from {} to {}. {}: {}zFailed to create bucket z. z: zUploaded from %s to %szCreated bucket %sZDELETE�2z*Failed to delete {} from bucket {}. {}: {}zFailed to delete bucket zDeleted %s from bucket %szDeleted bucket %szFailed to get file. zSaving to local file: %s�wb)�
chunk_sizezSaved to local file: zFailed s3 operation. r)+�HAS_REQUESTS�log�error�salt�utilsZawsZ
IROLE_CODEZget_locationZ	hashutilsZget_hash�urllib�parse�quote�formatZsig4�debug�filesZfopen�read�requests�request�closeZstatus_code�content�xmlZto_dict�ETZ
fromstring�KeyErrorZ
ParseError�type�__name__r�str�
startswithZiter_content�write�appendZcodes�ok�dictr�strip)%rZkeyid�method�paramsrrZ
return_urlZbucketZservice_url�pathZ
return_bin�actionZ
local_fileZ
verify_sslZfull_headersZ	kms_keyidrrrZ
path_styleZhttps_enableZendpointrZfhr�resultZerr_code�err_msgZerr_textZerr_data�err�out�chunk�items�ret�item�header�rH�A/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/s3.py�querys\G


�
�
�	�
��	�
�
����
����
������

�
�rJ)rNNNFNNrFNNTFNNNrFT)�__doc__�logging�urllib.parser$Zxml.etree.ElementTreeZetreeZElementTreer0Zsalt.utils.awsr"Zsalt.utils.filesZsalt.utils.hashutilsZsalt.utils.xmlutilr#Zxmlutilr/Zsalt.exceptionsrr+r�ImportError�	getLoggerr3r rJrHrHrHrI�<module>sH�
�