Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /usr/lib/python2.7/site-packages/slip/util/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python2.7/site-packages/slip/util/files.pyc
�
��9Qc@s�dZdddddgZddlZddlZddlZddlZddlZdZd	�Zgd
�Z	d�Z
eed�Zeed
�Z
eed�Zeed�ZdS(s=This module contains helper functions for dealing with files.t
issamefiletlinkfiletcopyfiletlinkorcopyfiletoverwrite_safelyi����NicCs1tj|�}tj|�}tjj||�S(N(toststattpathtsamestat(tpath1tpath2ts1ts2((s3/usr/lib/python2.7/site-packages/slip/util/files.pyt_issamefile#scCs?|tkrt}nyt||�SWn|k
r:tSXdS(sECheck whether two paths point to the same file (i.e. are hardlinked).N(tTruet	ExceptionR
tFalse(R	R
tcatch_stat_exceptions((s3/usr/lib/python2.7/site-packages/slip/util/files.pyR*s	
cCs�t||dt�rdStjj|�}tjj|�}tjj|�}t}xtt	j
�D]n}t	jd|tjd|�}ytj
||�Wn+tk
r�}|jtjkr�q��qeXt}PqeW|r�tj||�ndS(sUHardlink srcpath to dstpath.

    Attempt to atomically replace dstpath if it exists.RNtprefixtdir(RtOSErrorRRtabspathtdirnametbasenameRtxrangettempfiletTMP_MAXtmktemptextseptlinkterrnotEEXISTRtrename(tsrcpathtdstpathtdstdnametdstbnamet
hardlinkedtattemptt_dsttmpte((s3/usr/lib/python2.7/site-packages/slip/util/files.pyR6s$c
Cs�t||dt�rdStjj|�}tjj|�}tjj|�}t|d�}tj	d|tjj
d|dt�}t}|r�ytj
||j�t}Wq�tjtfk
r�q�Xn|s�tj
||j�nd}	xa|	dkrT|jt�}	y|j|	�Wq�|j�|j�tj|j��q�Xq�W|j�|j�tj|j|�|r�tj�dkr�tj|�ndS(	s�Copy srcpath to dstpath.

    Abort operation if e.g. not enough space is available.  Attempt to
    atomically replace dstpath if it exists.RNtrbRRtdeleteti(RRRRRRRtopenRtNamedTemporaryFileRRtshutiltcopymodetnameRtErrortNonetreadt	BLOCKSIZEtwritetclosetunlinkR tselinuxtis_selinux_enabledt
restorecon(
R!R"tcopy_mode_from_dsttrun_restoreconR#R$tsrcfilet
dsttmpfiletmode_copiedtdata((s3/usr/lib/python2.7/site-packages/slip/util/files.pyRWs@




cCsiyt||�dSWn:tk
rQ}|jtjtjtjfkrR�qRnXt||||�dS(stFirst attempt to hardlink srcpath to dstpath, if hardlinking isn't
    possible, attempt copying srcpath to dstpath.N(RRRtEMLINKtEPERMtEXDEVR(R!R"R;R<R(((s3/usr/lib/python2.7/site-packages/slip/util/files.pyR�s
!c
Cstjj|�}tjj|�}t}d}|rQtj�dkrQt}nly8tj|�\}}|dkr�t	d|��nWn1t
k
r�}	|	jtjkr�t
}q��nX|s�tj||�|r�tj|�q�nd}
x�ttj�D]q}tjd|tjd|�}ytj||�Wn.t
k
rk}	|	jtjkreqn�qX|}
PqW|
dkr�ttjd��n|r�|r�tj|
|�nytj|
|�Wntj|
��nX|r�tj|�ndS(spCreate a symlink, optionally replacing dstpath atomically, optionally
    setting or preserving SELinux context.isgetfilecon(%r) failedRRs/No suitable temporary symlink could be created.N(RRRRRR2R8R9tlgetfilecontRuntimeErrorRRtENOENTRtsymlinkR:RRRRRRtIOErrortlsetfileconR tremove(
R!R"tforcetpreserve_contextR#R$R<tctxtretR(tdsttmpR&R'((s3/usr/lib/python2.7/site-packages/slip/util/files.pytsymlink_atomically�sR			

cCs�tjj|�}tjj|�}tjj|�}d}d}d}tjj|�}	|r{tj�dkr{t	}nzt
jd|tjjd|�\}}|	r�|r�t
j||�n|	r|rtj|�\}
}|
dkrtd|��qntj|d�}d}|j|�|j�d}tj||�|r||	rltj||�q|tj|�nWd|r�|j�n|r�tj|�n|r�tjj|�r�ytj|�Wq�q�XnXdS(s�Safely overwrite a file by creating a temporary file in the same
    directory, writing it, moving it over the original file, eventually
    preserving file mode and SELinux context.iRRsgetfilecon(%r) failedtwN(RRtrealpathRRR2texistsR8R9RRtmkstempRR.R/t
getfileconREtfdopenR5R6R t
setfileconR:tisfileR7(Rtcontentt
preserve_modeRLtdir_tbasetfdtfttmpnameRSRNRM((s3/usr/lib/python2.7/site-packages/slip/util/files.pyR�sJ	


(t__doc__t__all__RR8R.RRR4R
RRRRRRRPR(((s3/usr/lib/python2.7/site-packages/slip/util/files.pyt<module>s 			!6;

ZeroDay Forums Mini