403Webshell
Server IP : 3.96.16.70  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3.9/site-packages/cfnbootstrap/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/cfnbootstrap/__pycache__/file_tool.cpython-39.pyc
a

��0i�0�@s�ddlmZmZddlmZddlmZddlZddlZddl	Z	ddl
Z
ddlmZddl
Z
ddlZddlZddlZe�d�ZGdd�de�ZdS)	�)�security�util)�	ToolError)�contextmanagerN)�requestszcfn.initc@s�eZdZdZdZedd��Zedd��Zedd��Zd	d
�Z	e
dd��Zd
d�Zdd�Z
dd�Zdd�Ze��dd��Zdd�ZdS)�FileToolz
    Writes files to disk

    � cCsFttjd�rtj�||�Stj�tj�|��tj�tj�|��kSdS)N�samefile)�hasattr�os�pathr	�normcase�abspath)�cls�f1�f2�r�:/usr/lib/python3.9/site-packages/cfnbootstrap/file_tool.py�is_same_file(szFileTool.is_same_filec	Cs�tj�|�tj�|�krdS|�||�r,dSt|d���}t|d��n}d}|�|�}|�|�}||kr�Wd�Wd�dS|sHWd�Wd�dSqHWd�n1s�0YWd�n1s�0YdS)zA
        Return true if f1 and f2 have the same content.
        FT�rbrN)rr�getsizer�open�read)rrr�fp1�fp2�bufsize�b1�b2rrr�compare_file_contents0s

zFileTool.compare_file_contentscCs4tj�|�rdStj�d�r0t�|�p.|�d�SdS)a2
        Compatibility version of os.path.isabs:
        - On Unix: use os.path.isabs() as usual.
        - On Windows: also treat '/tmp/...', '/var/...', and similar Unix-style
            root paths as absolute (for backward compatibility with older
            cfn-bootstrap / Python versions).
        T�win�/F)rr�isabs�sys�platform�
startswith�ntpath)rrrrr�
is_abs_compatFs
zFileTool.is_abs_compatc
Cs�g}|��st�d�|St|��dd�d�D�]�\}}|�|�sNtd|��d|voht�t	|dd��}|r�d|vr�td	��n2t
j�|�r�t
�t
j�|�|d�r�t�d
|�q.t
j�|�}t
j�|�s�t
j�|�s�t�d|�t
�|�ntd|��d
}t
j�|��r"d}t�t
�|�j�}	|�||����|�r\t�d||d�t
�|d|�n�d|v�op|�|�}
t�d|�|
�r�t|ddd��}|�|||�Wd�n1�s�0Yn:t|d��}|�|||�Wd�n1�s�0Yd|v�r8t�d||d�t
�|t�t	|dd���n^|�r^t�d|t|	��t
�||	�n8t�t
�|�j�}	|	d@}	t�d|t|	��t
�||	�t�||� d�|� d��Wd�q.1�s�0Yq.|S)at
        Write a set of files to disk, returning a list of the files that have changed.

        Arguments:
        action -- a dict of pathname to attributes, such as owner, group, mode, content, and encoding
        auth_config -- an AuthenticationConfig object for managing authenticated downloads

        Exceptions:
        ToolError -- on expected failures
        zNo files specifiedcSs|dS)Nrr)Zpairrrr�<lambda>n�z FileTool.apply.<locals>.<lambda>)�keyz)File specified with non-absolute path: %s�mode��contentz-Symbolic link specified without a destinationzSymbolic link %s already existsz,Parent directory %s does not exist, creatingz(Parent directory %s exists and is a fileFTz(%s is specified as a symbolic link to %szWriting content to %s�w�utf-8)�encodingN�wbzSetting mode for %s to %szGNo mode specified for %s. Setting permissions of the existing file: %s.i�zDNo mode specified for %s. The file will be created with the mode: %s�owner�group)!�keys�log�debug�sorted�itemsr&r�stat�S_ISLNK�intrr�existsrr�realpath�info�dirname�isdir�makedirs�isfile�S_IMODE�st_mode�backup�symlink�
_is_base64r�_write_file�chmod�octrZset_owner_and_group�get)�self�action�auth_config�
files_changed�filename�attribsZfile_is_link�parentZcurrentFileExistsZcurrentFileModeZfile_is_text�frrr�apply\s�

���$����0.
�
�
�
��&zFileTool.applyc
cs�d}d}tj�|�rjt�d|�|d}tj�|�r^|d}tj�|�rRt�|�|�||�|�||�z
|VWn�ty�|r�z6tj�|�r�t�|�|�||�|r�|�||�Wn0ty�}zt�	d|�WYd}~n
d}~00�Yn�0|�r
tj�
|��ptj�
|�}|�r0|�s0t�||��sL|�
|�|�r�t�|�nV|�r�|�r�z|�||�Wn8t�y�}zt�	d|t|��WYd}~n
d}~00dS)Nz%s already existsz.bak�2zError restoring %s from backupz"Error restoring backup file %s: %s)rrr;r4r5�remove�_backup_file�	Exceptionr�warn�islinkrr�append�str)rKrOrNZbackup_fileZbackup_backup_file�tZlinkmoderrrrD�sP


"�
�
�zFileTool.backupc
Csjzt�d||�t�||�WnFtyd}z.t�d||�td|t|�f��WYd}~n
d}~00dS)NzMoving %s to %szCould not move %s to %szCould not rename %s: %s)r4r5r�rename�OSError�errorrr[)rK�source�dest�errrrV�szFileTool._backup_filecCs|�dd�dkS)Nr/Zplain�base64)rJ)rKrPrrrrF�szFileTool._is_base64c
Cs�|�dd�}|r.|�|||�|�|�d��n�|�dd�}|sFtd��t�d|�z(|�||�|�dd��||�d��Wn6ty�}ztd||j	f��WYd}~n
d}~00dS)	Nr,��contextr`z(File specified without source or contentzRetrieving contents from %sZauthenticationzFailed to retrieve %s: %s)
rJ�_write_inline_contentrFrr4r5�_write_remote_fileZget_auth�IOError�strerror)rKZdest_fileobjrPrMr,r`rbrrrrG�s"���zFileTool._write_filec
Cst�d�z8ddl}t|t�r,|�||�WS|�|�d�|�WSWnVty^t�d�Yn<ty�}z$t	dt
|dt|����WYd}~n
d}~00z"ddlm
}|d	d	d
��||�WSty�t	d��Yn>t�y}z$t	dt
|dt|����WYd}~n
d}~00dS)zZTries rendering template with chevron first. If chevron is not present then uses pystache.zRendering as Mustache templaterNzUTF-8z(Chevron is not installed trying pystachez3Failed to render content as a Mustache template: %s�message)�Rendererr.)Zstring_encoding�
file_encodingzDFailed to render the template since pystache and chevron are missing)r4r5�chevron�
isinstancer[Zrender�decode�ImportErrorrWr�getattr�reprZpystache.rendererrk)rKr,rermrbrkrrr�_render_template�s"

.zFileTool._render_templatecCsXt�d|i�}t�tj|fi|���}|dur:|�|�n|�|�|��|��	��dS)N�auth)
rZreq_optsZEtagCheckedResponserrJZwrite_to�writers�contents�encode)rKr`rtrareZoptsZremote_contentsrrrrgs��zFileTool._write_remote_filec	Cs�t|t�s$t�d�t�||�dS|rrz"t�d�|�t�|�	���Wq�t
tjfynt
d|��Yq�0n&|dur�|�|�n|�|�||��dS)Nz.Content will be serialized as a JSON structurezDecoding base64 contentzMalformed base64: %s)rnr[r4r5�json�dumprurcZ	b64decode�strip�	TypeError�binascii�Errorrrs)rKrar,Z	is_base64rerrrrf s


zFileTool._write_inline_contentN)�__name__�
__module__�__qualname__�__doc__Z_compare_buffer�classmethodrrr&rSrrDrVrFrGrsrZretry_on_failurergrfrrrrr s$


[
)
r)ZcfnbootstraprrZ cfnbootstrap.construction_errorsr�
contextlibrrcZloggingrr"Zcfnbootstrap.packagesrr8r|rxr%Z	getLoggerr4�objectrrrrr�<module>s


Youez - 2016 - github.com/yon3zu
LinuXploit