403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /usr/lib64/python3.9/site-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/lib64/python3.9/site-packages/mercurial/__pycache__/chgserver.cpython-39.pyc
a

�+�bi�@sVdZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZddlmZddlmZmZmZmZmZmZdd	lmZmZmZd
d�Zgd�Zd
gZe�dej�Z dd�Z!dd�Z"dd�Z#Gdd�de$�Z%dd�Z&dd�Z'Gdd�de$�Z(gd�Z)Gdd�dej*�Z+d d!�Z,d"d#�Z-Gd$d%�d%e$�Z.d&d'�Z/dS)(aRcommand server extension for cHg

'S' channel (read/write)
    propagate ui.system() request to client

'attachio' command
    attach client's stdio passed by sendmsg()

'chdir' command
    change current directory

'setenv' command
    replace os.environ completely

'setumask' command (DEPRECATED)
'setumask2' command
    set umask

'validate' command
    reload the config and check if the server is up to date

Config
------

::

  [chgserver]
  # how long (in seconds) should an idle chg server exit
  idletimeout = 3600

  # whether to skip config or env change checks
  skiphash = False
�)�absolute_importN�)�_)�getattr�setattr)�hex)�
commandserver�encoding�error�
extensions�pycompat�util)�hashutil�procutil�
stringutilcCstt�t�|�����S)z return sha1 hexdigest for a list)rrZsha1r�pprint�digest)�items�r�9/usr/lib64/python3.9/site-packages/mercurial/chgserver.py�	_hashlistKsr)saliass
diff-toolsseolsextdiffs
extensionssfastannotatesmerge-toolssschemes)scommandssshow.aliasprefixs~\A(?:
                    CHGHG
                    |HG(?:DEMANDIMPORT|EMITWARNINGS|MODULEPOLICY|PROF|RCPATH)?
                    |HG(?:ENCODING|PLAIN).*
                    |LANG(?:UAGE)?
                    |LC_.*
                    |LD_.*
                    |PATH
                    |PYTHON.*
                    |TERM(?:INFO)?
                    |TZ
                    )\Zcs�g}tD]}|�|�|��qtD]\}}|�|�||��q"t|�}dtjvrXdh�nt���fdd�t	�
tj�D�}tt|��}|dd�|dd�S)a�return a quick hash for detecting config/env changes

    confighash is the hash of sensitive config items and environment variables.

    for chgserver, it is designed that once confighash changes, the server is
    not qualified to serve its client and should redirect the client to a new
    server. different from mtimehash, confighash change will not mark the
    server outdated and exit since the user can have different configs at the
    same time.
    sCHGHGsHGcs*g|]"\}}t�|�r|�vr||f�qSr)�_envre�match��.0�k�v�Zignoredrr�
<listcomp>�s�z_confighash.<locals>.<listcomp>N�)�_configsections�appendZconfigitems�_configsectionitemsZconfigrr	�environ�setr�	iteritems�sorted)�uiZsectionitems�section�itemZsectionhashZenvitemsZenvhashrrr�_confighashrs


�r*c	Cs�dd�t�|�D�}zddlm}|�|�Wnty@Yn0g}tjrX|�tj�|D]2}z|�t�t�	|���Wq\t
y�Yq\0q\tt|��S)z�get a list of paths that should be checked to detect change

    The list will include:
    - extensions (will not cover all files for complex extensions)
    - mercurial/__version__.py
    - python binary
    cSsg|]\}}|�qSrr)r�n�mrrrr��z"_getmtimepaths.<locals>.<listcomp>r)�__version__)
r�r.r!�ImportErrorrZ
sysexecutable�fsencode�inspectZ
getabsfile�	TypeErrorr&r$)r'�modulesr.�filesr,rrr�_getmtimepaths�sr6cCs dd�}tt�||��dd�S)aWreturn a quick hash for detecting file changes

    mtimehash calls stat on given paths and calculate a hash based on size and
    mtime of each file. mtimehash does not read file content because reading is
    expensive. therefore it's not 100% reliable for detecting content changes.
    it's possible to return different hashes for same file contents.
    it's also possible to return a same hash for different file contents for
    some carefully crafted situation.

    for chgserver, it is designed that once mtimehash changes, the server is
    considered outdated immediately and should no longer provide service.

    mtimehash is not included in confighash because we only know the paths of
    extensions after importing them (there is imp.find_module but that faces
    race conditions). We need to calculate confighash without importing.
    cSs4zt�|�}|tj|jfWSty.Yn0dS�N)�os�stat�ST_MTIME�st_size�OSError)�path�strrr�trystat�s

z_mtimehash.<locals>.trystatN�)rrZmaplist)�pathsr?rrr�
_mtimehash�srBc@s&eZdZdZdd�Zeddd��ZdS)�	hashstatezCa structure storing confighash, mtimehash, paths used for mtimehashcCs||_||_||_dSr7)�
confighash�	mtimehash�
mtimepaths)�selfrDrErFrrr�__init__�szhashstate.__init__NcCs<|durt|�}t|�}t|�}|�dd||�t|||�S)Ns	cmdserversconfighash = %s mtimehash = %s
)r6r*rB�logrC)r'rFrDrErrr�fromui�s�zhashstate.fromui)N)�__name__�
__module__�__qualname__�__doc__rH�staticmethodrJrrrrrC�srCcs"G���fdd�d|j���|�S)Ncs8eZdZd���fdd�	Zdd�Zd	�fdd�	Z�ZS)
z_newchgui.<locals>.chguiNcs.t�|��|�|r$t|d��|_n�|_dS)N�_csystem)�superrHrrP)rG�src)�	__class__�chgui�csystemrrrH�sz!_newchgui.<locals>.chgui.__init__cSs`||jus2t�|jd�r2|j��tj��ks2|jrDtj||||d�S|��|�	|t�
|�|�S)Nsfileno)r#�cwd�out)�foutr
�safehasattr�filenor�stdoutZ_finoutredirected�system�flushrP�shellenviron)rG�cmdr#rVrWrrr�
_runsystem�s����z#_newchgui.<locals>.chgui._runsystemcs |j|t�|�dd�id�dS)N�pager�attachio)�type�cmdtableT)rPrr^)rGr_�env)�attachiorr�	_runpager�s�z"_newchgui.<locals>.chgui._runpager)N)N)rKrLrMrHr`rg�
__classcell__r�rfrTrU�rSrrT�srTrj)�srcuirUrfrrir�	_newchgui�s!rlcCs(ddlm}|j��}dD]}t||t||��qt�|d�rF|j|_|�	||�}|�
||d�|��D]B\}}}	|�||�}
d|
vsj|
dksj|
�
d�r�qj|�|||	|
�qj|d	}|r�tj�|�p�d}|d
}|j|||d�\}
}t�|�tj||d�||u�r t�|�tj||d�||fS)
Nr)�dispatch)�fin�fout�ferrsenvirons_csystemsconfig�:s--config�$scwds
repository)Zwd)�fp)r/rmrS�loadrrr
rYrPZ_earlyparseoptsZ_parseconfigZ
walkconfigZconfigsource�
startswith�	setconfigr8r=�realpathZ	_getlocalrZ
populateuirZsetuplogging)rk�args�cdebugrmZnewui�a�optionsr(�name�value�sourcerVZrpathr=Znewluirrr�
_loadnewuis.



rc@s"eZdZdZdd�Zddd�ZdS)	�channeledsystema�Propagate ui.system() request in the following format:

    payload length (unsigned int),
    type, '',
    cmd, '',
    cwd, '',
    envkey, '=', val, '',
    ...
    envkey, '=', val

    if type == 'system', waits for:

    exitcode length (unsigned int),
    exitcode (int)

    if type == 'pager', repetitively waits for a command name ending with '
'
    and executes it defined by cmdtable, or exits the loop if the command name
    is empty.
    cCs||_||_||_dSr7)�in_rW�channel)rGr�rWr�rrrrH=szchanneledsystem.__init__N�systemc
Cs ||t�|pd�g}|�dd�t�|�D��d�|�}|j�t�	d|j
t|���|j�|�|j��|dkr�|j
�d�}t�d|�\}|dkr�t�td	���t�d
|j
�d��\}	|	S|dk�r|j
��dd�}|s�q|r�||vr�||�q�t�td
�|��q�nt�d|��dS)N�.css|]\}}d||fVqdS)s%s=%sNrrrrr�	<genexpr>Dr-z+channeledsystem.__call__.<locals>.<genexpr>��>cIr���>Isinvalid response�>ira���sunexpected command: %ssinvalid S channel type: %s)r
�abspath�extendrr%�joinrW�write�struct�packr��lenr]r��read�unpackr
ZAbortr�readlineZProgrammingError)
rGr_r#rVrcrdrx�data�length�rcrrr�__call__Bs*


zchanneledsystem.__call__)Nr�N)rKrLrMrNrHr�rrrrr�(sr�))scinrn�rb)scoutro�wb)scerrrpr�c	s�eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Z�fdd�Z
dd�Zejj��Ze�ee	e
ee
ed��e�ed�r�dd�Zeed<�ZS)�chgcmdserverc		sltt|��t|t||d�|j�||||�||_d|_g|_||_	||_
|durh|j��|_tj
|jd<dS)N�SFsvalidate)rQr�rHrlr�rf�
clientsock�_ioattached�_oldiosrC�baseaddress�capabilities�copy�validate)	rGr'�repo�finrX�sock�
prereposetupsrCr�rjrrrHgs
�zchgcmdserver.__init__cs*tt|���|j��|��d|_dS�NF)rQr��cleanupr'r]�
_restoreior��rGrjrrr�zs
zchgcmdserver.cleanupc
Cs:|j�t�ddd��t�|j���}|j�dd|�|j}|�	�|�
�t|t�D]�\}\}}}|dkspJ�t
||�}t�||���t�|�|jr�qV|dkr�|}nJtjr�|��r�t�|�}q�t�|�}n$|��r�d}	nd}	t�|��||	�}||u�r
t|||�t|||�qVd	|_|j�t�d
t|���dS)z{Attach to client's stdio passed via unix domain socket; all
        channels except cresult will no longer be used
        r��Ir�	chgserversreceived fds: %r
rrpr�Tr�N)r�Zsendallr�r�r
ZrecvfdsrZr'rIr]�_saveio�zip�_iochannelsrr8�dup2�closer�r�ispy3�isattyrZmake_line_bufferedZunwrap_line_buffered�fdopenr�cresultr�r�)
rGZ	clientfdsr'�fd�cn�fn�moders�newfp�bufsizerrrrf�s8


zchgcmdserver.attachiocCsX|jr
dS|j}tD]>\}}}t||�}t||�}t�|���}|j�|||f�qdSr7)r�r'r�rr8�duprZr!)rGr'r�r��_mode�chrsr�rrrr��s

zchgcmdserver._saveiocCs|js
dSt�tjtj�}|j}t|jt�D]�\\}}}\}}}t||�}	t	j
s`|	|us`|	��zLt	j
sp|	|ur�d|vr�t�||�
��|��t�||�
��t�|�Wn<ty�}
z$|j�ddt�|
�|�WYd}
~
n
d}
~
00t|||�t|||�q,t�|�|jdd�=dS)N�wr�sgot %s while duplicating %s
)r�r8�open�devnull�O_WRONLYr'r�r�rrr�r�r�rZr]r<rIr�forcebytestrr)rGZnullfdr'r�rsr�r�r�r�r��errrrrr��s2 
�
zchgcmdserver._restoreioc

Cs�|��}d}d}zt|j||j�\|_}Wn�tjy�}zF|j�td�t�|��|j	rr|j�td�|j	�d}WYd}~nRd}~0tj
y�}z0|jdur�|j}|j�|���d}WYd}~n
d}~00|�r|j�
�d}|j�dd�r�|}|j�d	|�dSt�||jj�}g}|j|jjk�rdt|j|jj�}	|�d
|	�|jj�rd|�d�|j|jjk�r�t|j|j�}	|�d|	�|j�d
dt�|��|j�d�|��p�d�dS)a�Reload the config and check if the server is up to date

        Read a list of '' separated arguments.
        Write a non-empty list of '' separated instruction strings or ''
        if the list is empty.
        An instruction string could be either:
            - "unlink $path", the client should unlink the path to stop the
              outdated server.
            - "redirect $path", the client should attempt to connect to $path
              first. If it does not work, start a new server. It implies
              "reconnect".
            - "exit $n", the client should exit directly with code n.
              This may happen if we cannot parse the config.
            - "reconnect", the client should close the connection and
              reconnect.
        If neither "reconnect" nor "redirect" is included in the instruction
        list, the client can continue with this server after completing all
        the instructions.
        F�s
abort: %s
s(%s)
TNsuisdetailed-exit-codesexit %ds	unlink %ss	reconnectsredirect %sr�s
validate: %s
r�)�	_readlistrr'ryr
Z	RepoErrorrrr��hint�Error�detailed_exit_code�formatr]�
configboolr�r�rCrJrFrE�_hashaddressr�rDr!rIrr�)
rGrxZerrorraisedr�Zlui�instZ	exit_codeZnewhashZinstsZaddrrrrr��sD



zchgcmdserver.validatecCs.|��}|sdS|j�dd|�t�|�dS)z�Change current directory

        Note that the behavior of --cwd option is bit different from this.
        It does not affect --config parameter.
        Nr�schdir to '%s'
)�_readstrr'rIr8�chdir)rGr=rrrr�"s
zchgcmdserver.chdircCs|�|�d��dS)zChange umask (DEPRECATED)r�N)�	_setumaskZ_readr�rrr�setumask.szchgcmdserver.setumaskcCs*|��}t|�dkrtd��|�|�dS)zChange umaskr�s(invalid mask length in setumask2 requestN)r�r��
ValueErrorr�)rGr�rrr�	setumask24szchgcmdserver.setumask2cCs.t�d|�d}|j�dd|�t�|�dS)Nr�rr�ssetumask %r
)r�r�r'rIr
r�)rGr��maskrrrr�;szchgcmdserver._setumaskcs@|j}g|_ztt|���W|��||_S|��||_0dSr7)r�rQr��
runcommandr�)rGZglobaloldiosrjrrr�@s��zchgcmdserver.runcommandcCsl|��}ztdd�|D��}Wnty8td��Yn0|j�ddt|����tj�	�tj�
|�dS)ztClear and update os.environ

        Note that not all variables can make an effect on the running process.
        css|]}|�dd�VqdS)�=rN)�split)r�srrrr�Sr-z&chgcmdserver.setenv.<locals>.<genexpr>s"unexpected value in setenv requestr�ssetenv: %r
N)r��dictr�r'rIr&�keysr	r#�clear�update)rG�lZnewenvrrr�setenvLs
zchgcmdserver.setenv)rbschdirs
runcommandssetenvssetumasks	setumask2ssetprocnamecCs&|��}|j�dd|�t�|�dS)zChange process titler�ssetprocname: %r
N)r�r'rIr�setprocname)rGr|rrrr�iszchgcmdserver.setprocname)rKrLrMrHr�rfr�r�r�r�r�r�r�r�r�r�serverr�r�r�r
rYrr�rhrrrjrr�fs21
)<��r�cCsd|t��fS)Ns	%s.%d.tmp)r8�getpid)�addressrrr�_tempaddressrsr�cCs6tj�|�\}}|�dd�d}dtj�||�|fS)Nr�rrs%s-%s)r8r=r�r�)r�Zhashstr�dirname�basenamerrrr�vsr�c@sleZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�chgunixservicehandlerz"Set of operations for chg servicesrcCs4||_d|_d|_d|_|�dd�|_t��|_dS)Nr�sidletimeout)r'�
_hashstate�_baseaddress�_realaddressZ	configint�_idletimeout�time�_lastactive)rGr'rrrrH�szchgunixservicehandler.__init__cCs(|�|�|��|�|�|��dSr7)�_inithashstate�_checkextensions�_bind�_createsymlink)rGr�r�rrr�
bindsocket�s

z chgunixservicehandler.bindsocketcCsF||_|j�dd�r$d|_||_dSt�|j�|_t||jj�|_dS)Nr�sskiphash)	r�r'r�r�r�rCrJr�rD�rGr�rrrr��sz$chgunixservicehandler._inithashstatecCs|js
dSt��rd|j_dS)Nr-)r�rZ	notloadedrEr�rrrr��sz&chgunixservicehandler._checkextensionscCs@t|j�}t�||�t�|�|_|�tj	�t�
||j�dSr7)r�r�r
Zbindunixsocketr8r9�_socketstatZlisten�socketZ	SOMAXCONN�rename)rGr��tempaddressrrrr��s

zchgunixservicehandler._bindcCsB|j|jkrdSt|j�}t�tj�|j�|�t�||j�dSr7)	r�r�r�r8�symlinkr=r�r
r�)rGr�rrrr��s

z$chgunixservicehandler._createsymlinkcCsLz2t�|j�}|j|jjko0|tj|jtjkWStyFYdS0dSr�)r8r9r��st_inor�r:r<)rGr>rrr�_issocketowner�s�z$chgunixservicehandler._issocketownercCs|��sdSt�|j�dSr7)r�r
Z	tryunlinkr�r�rrr�unlinksocket�sz"chgunixservicehandler.unlinksocketcCsH|��s|j�dd|j�dSt��|j|jkrD|j�dd�dSdS)Nr�s%s is not owned, exiting.
Tsbeing idle too long. exiting.
F)r�r'rIr�r�r�r�r�rrr�
shouldexit�s�z chgunixservicehandler.shouldexitcCst��|_dSr7)r�r�r�rrr�
newconnection�sz#chgunixservicehandler.newconnectionc	Cst|j||||||j|j�Sr7)r�r'r�r�)rGr�Zconnr�rXr�rrr�createcmdserver�s�z%chgunixservicehandler.createcmdserverN)rKrLrMrNZpollintervalrHr�r�r�r�r�r�r�r�r�r�rrrrr�s		
	r�cCs�dtjvrtjd=dtjvr6tjdtjd<tjd=n$dtjvrZdtjvrRtjd=tjd=|rn|�dddd�t|�}tj|d||d	�S)
NsCHGINTERNALMARKsCHGORIG_LC_CTYPEsLC_CTYPEsCHG_CLEAR_LC_CTYPEsbundlesmainreporootr-srepo)r��optsZhandler)r	r#rvr�rZunixforkingservice)r'r�r�hrrr�chgunixservice�s




r)0rNZ
__future__rr2r8�rer�r9r�r�Zi18nrrrrZnoderr/rr	r
rr
Zutilsrrrrr r"�compile�Xrr*r6rB�objectrCrlrr�r�r�r�r�r�r�rrrrr�<module>sH" 	��%$6	j

Youez - 2016 - github.com/yon3zu
LinuXploit