HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/asyncssh/__pycache__/process.cpython-310.pyc
o

�h��@s�dZddlZddlmZmZmZddlZddlZddlZddl	Z	ddl
mZddlZddl
Z
ddlmZddlmZmZmZmZmZmZmZddlmZmZmZmZmZmZddlmZmZm Z m!Z!m"Z"dd	l#m$Z$m%Z%d
dl&m'Z'm(Z(m)Z)d
dl*m+Z+m,Z,d
d
l-m.Z.d
dl/m0Z0m1Z1m2Z2m3Z3m4Z4d
dl/m5Z5m6Z6m7Z7m8Z8d
dl/m9Z9m:Z:m;Z;d
dl<m=Z=d
dl>m?Z?m@Z@mAZAd
dl>mBZBmCZCd
dl>mDZDe deEeFdd�ZGe!eeEdfZHe!eIeFejee?eEejJeHfZKe!eIeFejee@eEejLeHfZMedge2dfZNdZOdZPGdd�de$e�ZQGdd�de$�ZRGd d!�d!e$eG�ZSd"eeEd#eTfd$d%�ZUGd&d'�d'eRee�ZVGd(d)�d)eSe�ZWGd*d+�d+eVe�ZXGd,d-�d-eVe�ZYGd.d/�d/eWe�ZZGd0d1�d1eWe�Z[Gd2d3�d3eVeej\�Z]Gd4d5�d5eWeej\�Z^Gd6d7�d7eRee�Z_Gd8d9�d9eSe�Z`Gd:d;�d;eVe�ZaGd<d=�d=eWe�ZbGd>d?�d?eSe�ZcGd@dA�dAeSe�ZdGdBdC�dCe1�ZeGdDdE�dEeeejf�ZfGdFdG�dGe6�ZgGdHdI�dIeAee�ZhGdJdK�dKeheeBe�ZiGdLdM�dMeheeCe�ZjdS)NzSSH process handlers�N)�DEVNULL�PIPE�STDOUT)�PurePath)�
TracebackType)�Any�AnyStr�	Awaitable�Callable�Dict�Generic�IO)�Iterable�List�Mapping�Optional�Set�TextIO)�Tuple�Type�TypeVar�Union�cast)�Protocol�Self�)�
SSHChannel�SSHClientChannel�SSHServerChannel)�DEFAULT_LANG�EXTENDED_DATA_STDERR)�	SSHLogger)�
BytesOrStr�Error�
MaybeAwait�	TermModes�TermSize)�
ProtocolError�Record�	open_file�set_terminal_size)�
BreakReceived�SignalReceived�TerminalSizeChanged)�DataType)�	SSHReader�	SSHWriter�SSHStreamSession)�SSHClientStreamSession�SSHServerStreamSession)�SFTPServerFactory�
_AnyStrContraT)�
contravariantz_AsyncFileProtocol[bytes]zSSHServerProcess[AnyStr]��c@s@eZdZdZd
dedefdd�Zdeddfd	d
�Zddd�ZdS)�_AsyncFileProtocolzProtocol for an async file����n�returnc���dS)zRead from an async fileN�)�selfr;r>r>�F/usr/local/CyberPanel/lib/python3.10/site-packages/asyncssh/process.py�readK�z_AsyncFileProtocol.read�dataNc�r=)zWrite to an async fileNr>�r?rCr>r>r@�writeNrBz_AsyncFileProtocol.writec�r=)zClose an async fileNr>�r?r>r>r@�closeQrBz_AsyncFileProtocol.close)r:�r<N)	�__name__�
__module__�__qualname__�__doc__�intrrArErGr>r>r>r@r9Hs
r9c@s.eZdZdZd
dd�Zd
dd�Zd
dd	�ZdS)�_ReaderProtocolz2A class that can be used as a reader in SSHProcessr<NcC�dS)z
Pause readingNr>rFr>r>r@�
pause_readingX�z_ReaderProtocol.pause_readingcCrO)zResume readingNr>rFr>r>r@�resume_reading[rQz_ReaderProtocol.resume_readingcCrO�zStop forwarding dataNr>rFr>r>r@rG^rQz_ReaderProtocol.closerH)rIrJrKrLrPrRrGr>r>r>r@rNUs


rNc@sHeZdZdZdeddfdd�Zdeddfdd	�Zdd
d�Zddd
�Z	dS)�_WriterProtocolz2A class that can be used as a writer in SSHProcessrCr<NcCrO)z
Write dataNr>rDr>r>r@rEerQz_WriterProtocol.write�exccCrO)z5Write exception (break, signal, terminal size change)Nr>�r?rUr>r>r@�write_exceptionhsz_WriterProtocol.write_exceptioncCrO)z)Close output when end of file is receivedNr>rFr>r>r@�	write_eofmrQz_WriterProtocol.write_eofcCrOrSr>rFr>r>r@rGprQz_WriterProtocol.closerH)
rIrJrKrLr5rE�	ExceptionrWrXrGr>r>r>r@rTbs
rT�filer<cCs.zt�t�|���j�WStyYdSw)z8Return if argument is a regular file or file-like objectT)�stat�S_ISREG�os�fstat�fileno�st_mode�OSError)rZr>r>r@�_is_regular_filets
�rbcsbeZdZdZ	ddeededef�fdd�
Zdded	ed
e	fdd�Z
ddd�Zddd�Z�Z
S)�_UnicodeReaderz%Handle buffering partial Unicode dataF�encoding�errors�textmodec�0t���|r|st�|�|�|_dSd|_dS�N)�super�__init__�codecs�getincrementaldecoder�_decoder�r?rdrerf��	__class__r>r@rj�

�
z_UnicodeReader.__init__rC�finalr<c
CsV|jr$z
tt|j�||��}W|Sty#}ztt|��d�d}~wwtt|�}|S)z5Decode Unicode bytes when reading from binary sourcesN)rmrr�decode�UnicodeDecodeErrorr'�str)r?rCrr�decoded_datarUr>r>r@rs�s���
z_UnicodeReader.decodeNcCs|�dd�dS)z1Check if there's partial Unicode data left at EOF�TN)rsrFr>r>r@�
check_partial��z_UnicodeReader.check_partialcCrO)z@Perform necessary cleanup on error (provided by derived classes)Nr>rFr>r>r@rG�rQz_UnicodeReader.close�FrH)rIrJrKrLrru�boolrj�bytesrrsrxrG�
__classcell__r>r>ror@rc|s��


rccsHeZdZdZ	ddeededef�fdd�
Zded	e	fd
d�Z
�ZS)
�_UnicodeWriterz.Handle encoding Unicode data before writing itFrdrerfcrgrh)rirjrk�getincrementalencoder�_encoderrnror>r@rj�rqz_UnicodeWriter.__init__rCr<cCs>|jr|jdus
J�tt|j�tt|���}|Stt|�}|S)z3Encode Unicode bytes when writing to binary targetsN)r�rr|�encoderu)r?rC�encoded_datar>r>r@r��s
�z_UnicodeWriter.encoderz)rIrJrKrLrrur{rjrr|r�r}r>r>ror@r~�s��
r~csjeZdZdZdddeedededee	de	f�fd	d
�Z
dd
d�Zddd�Zddd�Z
ddd�Z�ZS)�_FileReaderzForward data from a file�process�SSHProcess[AnyStr]rZ�bufsize�datatyperdrecs8t��||t|d��||_||_||_||_d|_dS�NrdF)rirj�hasattr�_process�_file�_bufsize�	_datatype�_paused�r?r�rZr�r�rdreror>r@rj�s
z_FileReader.__init__r<NcCsX|js*|j�|j�}|r|j�|�|�|j�n
|��|j�	|j�dS|jrdSdS�zFeed file dataN�
r�r�rAr�r��	feed_datarsr�rx�feed_eofrDr>r>r@�feed�s�z_FileReader.feedcC�
d|_dS�zPause reading from the fileTN�r�rFr>r>r@rP��
z_FileReader.pause_readingcC�d|_|��dS�zResume reading from the fileFN�r�r�rFr>r>r@rR��z_FileReader.resume_readingcC�|j��dS�z"Stop forwarding data from the fileN)r�rGrFr>r>r@rG��z_FileReader.closerH)rIrJrKrLr
r|rMr.rrurjr�rPrRrGr}r>r>ror@r��s����


r�csteZdZdZdddeedededee	de	f�fd	d
�Z
dd
d�Zddd�Zddd�Z
ddd�Zddd�Z�ZS)�_AsyncFileReaderzForward data from an aiofiler�r�rZr�r�rdrecsDt��||t|d��|j��|_||_||_||_||_	d|_
dSr�)rirjr��channel�get_connection�_connr�r�r�r�r�r�ror>r@rj�s
z_AsyncFileReader.__init__r<Nc��`�|js.|j�|j�IdH}|r|j�|�|�|j�n
|��|j�	|j�dS|jrdSdSr�r�rDr>r>r@�_feed����z_AsyncFileReader._feedcC�|j�|���dS)zStart feeding file dataN�r��create_taskr�rFr>r>r@r��z_AsyncFileReader.feedcCr�r�r�rFr>r>r@rPr�z_AsyncFileReader.pause_readingcCr�r�r�rFr>r>r@rRr�z_AsyncFileReader.resume_readingcCs|j�|j���dSr�)r�r�r�rGrFr>r>r@rG�z_AsyncFileReader.closerH)rIrJrKrLr9r|rMr.rrurjr�r�rPrRrGr}r>r>ror@r��s$�����



r�cs`eZdZdZdeededeedef�fdd�Z	de
d	d
fdd�Zdd
d�Zddd�Z
�ZS)�_FileWriterzForward data to a filerZ�needs_closerdrecs&t��||t|d��||_||_dS)Nrd)rirjr�r��_needs_close)r?rZr�rdreror>r@rjs
z_FileWriter.__init__rCr<NcCs|j�|�|��dS)�Write data to the fileN)r�rEr�rDr>r>r@rE!r�z_FileWriter.writecC�|��dS�z.Close output file when end of file is receivedN�rGrFr>r>r@rX&�z_FileWriter.write_eofcCs|jr
|j��dSdS�z Stop forwarding data to the fileN)r�r�rGrFr>r>r@rG+s�z_FileWriter.closerH)rIrJrKrLr
r|r{rrurjrrErXrGr}r>r>ror@r�s��
r�csveZdZdZdddeededeedee	de	f�fd	d
�Z
dd
d�Zdeddfdd�Z
ddd�Zddd�Z�ZS)�_AsyncFileWriterzForward data to an aiofiler�r�rZr�r�rdrecsXt��||t|d��||_||_||_||_d|_t�	�|_
|j���
|���|_dSr�)rirjr�r�r�r�r�r��asyncio�Queue�_queuer�r�r��_writer�_write_task)r?r�rZr�r�rdreror>r@rj5s
�z_AsyncFileWriter.__init__r<Nc�s��	|j��IdH}|dur|j��n&|j�|�|��IdH|j��|jr9|j��tkr9|j	�
|j�d|_q|jrG|j�
�IdHdSdS)zProcess writes to the fileTNF)r��get�	task_doner�rEr�r��qsize�_QUEUE_LOW_WATERr��resume_feedingr�r�rGrDr>r>r@r�Cs�

��z_AsyncFileWriter._writerrCcC�@|j�|�|js|j��tkrd|_|j�|j�dSdSdS)r�TN�r��
put_nowaitr�r��_QUEUE_HIGH_WATERr��
pause_feedingr�rDr>r>r@rEW�
�z_AsyncFileWriter.writecCr�r�r�rFr>r>r@rX`r�z_AsyncFileWriter.write_eofcC�2|jrd|_|j�d�|j�|j���dSdSr��r�r�r�r��add_cleanup_task�joinrFr>r>r@rGe�
�z_AsyncFileWriter.closerH)rIrJrKrLr9r|r{rrMrurjr�rrErXrGr}r>r>ror@r�2s"�����

	r�cs�eZdZdZdddedeedef�fdd�Zd	ej	d
dfdd
�Z
deed
dfdd�Zde
d
dfdd�Zddd�Zddd�Zddd�Zddd�Z�ZS)�_PipeReaderzForward data from a piper�r�r�rdrecs$t��||�||_||_d|_dSrh)rirjr�r��
_transport�r?r�r�rdreror>r@rjqs
z_PipeReader.__init__�	transportr<NcCsttj|�|_dS)�Handle a newly opened pipeN)rr��
ReadTransportr�)r?r�r>r>r@�connection_madey�z_PipeReader.connection_maderUcCs|j�|j�|��dS�zHandle closing of the pipeN)r��
feed_closer�rGrVr>r>r@�connection_lost~sz_PipeReader.connection_lostrCcCs|j�|�|�|j�dS)zForward data from the pipeN)r�r�rsr�rDr>r>r@�
data_received�sz_PipeReader.data_receivedcCs|��|j�|j�dS)zForward EOF from the pipeN)rxr�r�r�rFr>r>r@�eof_received�sz_PipeReader.eof_receivedcC�|jdusJ�|j��dS)zPause reading from the pipeN)r�rPrFr>r>r@rP��z_PipeReader.pause_readingcCr�)zResume reading from the pipeN)r�rRrFr>r>r@rR�r�z_PipeReader.resume_readingcCr�)z"Stop forwarding data from the pipeN)r�rGrFr>r>r@rG�r�z_PipeReader.closerH)rIrJrKrLr.rrurjr��
BaseTransportr�rYr�r|r�r�rPrRrGr}r>r>ror@r�ns
��


r�cs�eZdZdZdddedeedef�fdd�Zd	ej	d
dfdd
�Z
deed
dfdd�Zddd�Z
ddd�Zded
dfdd�Zded
dfdd�Zddd�Zddd�Z�ZS)�_PipeWriterzForward data to a piper�r�r�rdrecs4t��||�||_||_d|_d|_t��|_dSrh)	rirjr�r�r��_ttyr��Event�_close_eventr�ror>r@rj�sz_PipeWriter.__init__r�r<NcCsRttj|�|_|�d�}t|jt�r%|��r'||_	t
|g|jj�R�dSdSdS)r��pipeN)rr��WriteTransportr��get_extra_info�
isinstancer��SSHServerProcess�isattyr�r*�	term_size)r?r�r�r>r>r@r��s
�z_PipeWriter.connection_maderUcCr�r�)r��setrVr>r>r@r��r�z_PipeWriter.connection_lostcC�|j�|j�dS)zPause writing to the pipeN�r�r�r�rFr>r>r@�
pause_writing�r�z_PipeWriter.pause_writingcCr�)zResume writing to the pipeN�r�r�r�rFr>r>r@�resume_writing�r�z_PipeWriter.resume_writingrCcCs$|jdusJ�|j�|�|��dS)zWrite data to the pipeN)r�rEr�rDr>r>r@rE�sz_PipeWriter.writecCs0t|t�r|jrt|jg|j�R�dSdSdS)z6Write terminal size changes to the pipe if it is a TTYN)r�r-r�r*r�rVr>r>r@rW�s�z_PipeWriter.write_exceptioncCr�)zWrite EOF to the pipeN)r�rXrFr>r>r@rX�r�z_PipeWriter.write_eofcCs.|jdusJ�|j��|j�|j���dS)z Stop forwarding data to the pipeN)r�rGr�r�r��waitrFr>r>r@rG�s
z_PipeWriter.closerH)rIrJrKrLr.rrurjr�r�r�rYr�r�r�rrErWrXrGr}r>r>ror@r��s
��



r�csHeZdZdZdddef�fdd�Zdd	d
�Zddd�Zdd
d�Z�Z	S)�_ProcessReaderz%Forward data from another SSH processr�r�r�c�t���||_||_dSrh�rirjr�r��r?r�r�ror>r@rj��

z_ProcessReader.__init__r<NcCr�)z$Pause reading from the other channelNr�rFr>r>r@rP�r�z_ProcessReader.pause_readingcCr�)z%Resume reading from the other channelNr�rFr>r>r@rR�r�z_ProcessReader.resume_readingcCr�)z+Stop forwarding data from the other channelN)r��clear_writerr�rFr>r>r@rG�r�z_ProcessReader.closerH)
rIrJrKrLr.rjrPrRrGr}r>r>ror@r��s

r�csbeZdZdZdddef�fdd�Zdedd	fd
d�Zdedd	fd
d�Z	ddd�Z
ddd�Z�ZS)�_ProcessWriterz#Forward data to another SSH processr�r�r�cr�rhr�r�ror>r@rj�r�z_ProcessWriter.__init__rCr<NcCs|j�||j�dS)zWrite data to the other channelN)r�r�r�rDr>r>r@rEr�z_ProcessWriter.writerUcCstt|j��|�dS)z'Write an exception to the other channelN)r�SSHClientProcessr��feed_exceptionrVr>r>r@rWr�z_ProcessWriter.write_exceptioncCr�)zWrite EOF to the other channelN)r�r�r�rFr>r>r@rX
r�z_ProcessWriter.write_eofcCr�)z)Stop forwarding data to the other channelN)r��clear_readerr�rFr>r>r@rGr�z_ProcessWriter.closerH)
rIrJrKrLr.rjrrErYrWrXrGr}r>r>ror@r��s
r�csreZdZdZdddejdededee	de	f�fd	d
�Z
dd
d�Zddd�Zddd�Z
ddd�Zddd�Z�ZS)�
_StreamReaderz#Forward data from an asyncio streamr�r��readerr�r�rdrecs<t��||�||_|j��|_||_||_||_d|_	dS�NF)
rirjr�r�r�r��_readerr�r�r�)r?r�r�r�r�rdreror>r@rjs
z_StreamReader.__init__r<Nc�r�)zFeed stream dataN)
r�r�rAr�r�r�rsr�rxr�rDr>r>r@r�(r�z_StreamReader._feedcCr�)zStart feeding stream dataNr�rFr>r>r@r�5r�z_StreamReader.feedcCr�)zPause reading from the streamTNr�rFr>r>r@rP:r�z_StreamReader.pause_readingcCr�)zResume reading from the streamFNr�rFr>r>r@rR?r�z_StreamReader.resume_readingcCrO)zAIgnore close -- the caller must clean up the associated transportNr>rFr>r>r@rGErQz_StreamReader.closerH)rIrJrKrLr��StreamReaderrMr.rrurjr�r�rPrRrGr}r>r>ror@r�s$�����



r�csteZdZdZdddejdedeedee	de	f�fd	d
�Z
dd
d�Zdeddfdd�Z
ddd�Zddd�Z�ZS)�
_StreamWriterz!Forward data to an asyncio streamr�r��writer�recv_eofr�rdrecsPt��||�||_||_||_||_d|_t��|_	|j
���|�
��|_dSr�)rirjr�r��	_recv_eofr�r�r�r�r�r�r�r�r�r�)r?r�r�r�r�rdreror>r@rjLs
�z_StreamWriter.__init__r<Nc�s��	|j��IdH}|dur|j��n+|j�|�|��|j��IdH|j��|jr>|j��t	kr>|j
�|j�d|_q|j
rI|j��dSdS)zFeed data to the streamTNF)r�r�r�r�rEr��drainr�r�r�r�r�r�r�rXrDr>r>r@r�Zs �

��z_StreamWriter._feedrCcCr�)zWrite data to the streamTNr�rDr>r>r@rEor�z_StreamWriter.writecCr�)zWrite EOF to the streamNr�rFr>r>r@rXxr�z_StreamWriter.write_eofcCr�)z"Stop forwarding data to the streamNr�rFr>r>r@rG}r�z_StreamWriter.closerH)rIrJrKrLr��StreamWriterr{rrMrurjr�rrErXrGr}r>r>ror@r�Is"�����

	r�c@s6eZdZdZdeddfdd�Zddd�Zdd	d
�ZdS)�_DevNullWriterzDiscard datarCr<NcCrO)zDiscard data being writtenNr>rDr>r>r@rE�rQz_DevNullWriter.writecCrO�zIgnore end of fileNr>rFr>r>r@rX�rQz_DevNullWriter.write_eofcCrO�zIgnore closeNr>rFr>r>r@rG�rQz_DevNullWriter.closerH)rIrJrKrLrrErXrGr>r>r>r@r�s

rcsHeZdZdZd�fdd�Zdeddfd	d
�Zddd�Zdd
d�Z�Z	S)�
_StdoutWriterz8Forward data to an SSH process' stdout instead of stderrr�r�cst���||_dSrh)rirjr�)r?r�ror>r@rj�s

z_StdoutWriter.__init__rCr<NcCs|j�|d�dS)z#Pretend data was received on stdoutN)r�r�rDr>r>r@rE�r�z_StdoutWriter.writecCrOrr>rFr>r>r@rX�rQz_StdoutWriter.write_eofcCrOrr>rFr>r>r@rG�rQz_StdoutWriter.close)r�r�rH)
rIrJrKrLrjrrErXrGr}r>r>ror@r�s
rcs|eZdZdZdefdeeeefdeedeedeedee	ee
eefdeed	ed
ededef�fd
d�
Z�Z
S)�ProcessErrora>SSH Process error

       This exception is raised when an :class:`SSHClientProcess` exits
       with a non-zero exit status and error checking is enabled. In
       addition to the usual error code, reason, and language, it
       contains the following fields:

         ============ ======================================= =================
         Field        Description                             Type
         ============ ======================================= =================
         env          The environment the client requested    `str` or `None`
                      to be set for the process
         command      The command the client requested the    `str` or `None`
                      process to execute (if any)
         subsystem    The subsystem the client requested the  `str` or `None`
                      process to open (if any)
         exit_status  The exit status returned, or -1 if an   `int` or `None`
                      exit signal is sent
         exit_signal  The exit signal sent (if any) in the    `tuple` or `None`
                      form of a tuple containing the signal
                      name, a `bool` for whether a core dump
                      occurred, a message associated with the
                      signal, and the language the message
                      was in
         returncode   The exit status returned, or negative   `int` or `None`
                      of the signal number when an exit
                      signal is sent
         stdout       The output sent by the process to       `str` or `bytes`
                      stdout (if not redirected)
         stderr       The output sent by the process to       `str` or `bytes`
                      stderr (if not redirected)
         ============ ======================================= =================

    ��env�command�	subsystem�exit_status�exit_signal�
returncode�stdout�stderr�reason�langcs�||_||_||_||_||_||_||_||_|r3|\}}}
}
d||
r)d|
nd|r/dnd}	n|r:d|��}	t��	|p@d|	|
�dS)NzProcess exited with signal z: rz (core dumped)z)Process exited with non-zero exit status r)
rr	r
rrr
rrrirj)r?rr	r
rrr
rrrr�signal�core_dumped�msgror>r@rj�s$�
�
zProcessError.__init__)rIrJrKrLrrrrurMrr{r"rjr}r>r>ror@r�s.(����������rc@seZdZdZdS)�TimeoutErroraGSSH Process timeout error

       This exception is raised when a timeout occurs when calling the
       :meth:`wait <SSHClientProcess.wait>` method on :class:`SSHClientProcess`
       or the :meth:`run <SSHClientConnection.run>` method on
       :class:`SSHClientConnection`. It is a subclass of :class:`ProcessError`
       and contains all of the fields documented there, including any output
       received on stdout and stderr prior to when the timeout occurred. It
       is also a subclass of :class:`asyncio.TimeoutError`, for code that
       might be expecting that.

    N)rIrJrKrLr>r>r>r@r�src@s�eZdZUdZeeeefed<eeed<eeed<eeed<ee	ee
eefed<eeed<eeed<eeed	<d
S)�SSHCompletedProcessaResults from running an SSH process

       This object is returned by the :meth:`run <SSHClientConnection.run>`
       method on :class:`SSHClientConnection` when the requested command
       has finished running. It contains the following fields:

         ============ ======================================= =================
         Field        Description                             Type
         ============ ======================================= =================
         env          The environment the client requested    `dict` or `None`
                      to be set for the process
         command      The command the client requested the    `str` or `None`
                      process to execute (if any)
         subsystem    The subsystem the client requested the  `str` or `None`
                      process to open (if any)
         exit_status  The exit status returned, or -1 if an   `int`
                      exit signal is sent
         exit_signal  The exit signal sent (if any) in the    `tuple` or `None`
                      form of a tuple containing the signal
                      name, a `bool` for whether a core dump
                      occurred, a message associated with the
                      signal, and the language the message
                      was in
         returncode   The exit status returned, or negative   `int`
                      of the signal number when an exit
                      signal is sent
         stdout       The output sent by the process to       `str` or `bytes`
                      stdout (if not redirected)
         stderr       The output sent by the process to       `str` or `bytes`
                      stderr (if not redirected)
         ============ ======================================= =================

    rr	r
rrr
rrN)rIrJrKrLrrru�__annotations__rMrr{r"r>r>r>r@r�s
"rc
s�eZdZdZdT�fdd�Zdefdd�Zdeee	d	ee	d
ee
defdd�Ze
deefd
d��Ze
defdd��Ze
deefdd��Ze
deefdd��Ze
deeeffdd��ZdUdededefdd�Z	dUdedededededdfd d!�Z	dUd"edededededdfd#d$�Zdedef�fd%d&�Z def�fd'd(�Z!d)e"ddfd*d+�Z#d,ee$ddf�fd-d.�Z%d/ededdf�fd0d1�Z&def�fd2d3�Z'dT�fd4d5�Z(dT�fd6d7�Z)d/ededdfd8d9�Z*deddfd:d;�Z+deddfd<d=�Z,ded>e-eddfd?d@�Z.deddfdAdB�Z/deddfdCdD�Z0dEee1dededdfdFdG�Z2deddfdHdI�Z3d>ee-edededdfdJdK�Z4deddfdLdM�Z5dTdNdO�Z6defdPdQ�Z7dTdRdS�Z8�Z9S)V�
SSHProcesszSSH process handlerr<Ncs6t�j|�g|_i|_i|_i|_i|_t�|_dSrh)	rirj�_cleanup_tasks�_readers�	_send_eof�_writersr�r��_paused_write_streams)r?�argsror>r@rj&szSSHProcess.__init__c�s�|S)z7Allow SSHProcess to be used as an async context managerr>rFr>r>r@�
__aenter__3s�zSSHProcess.__aenter__�	_exc_type�
_exc_value�
_tracebackc�s�|��|��IdHdS)z<Wait for a full channel close when exiting the async contextNF)rG�wait_closed)r?r r!r"r>r>r@�	__aexit__8s�zSSHProcess.__aexit__cC�|jdusJ�|jS)z'The channel associated with the processN)�_chanrFr>r>r@r�A�zSSHProcess.channelcCs|jdusJ�|jjS)z&The logger associated with the processN)r&�loggerrFr>r>r@r(HszSSHProcess.loggercC�|jdusJ�|j��S)z�The command the client requested to execute, if any

           If the client did not request that a command be executed,
           this property will be set to `None`.

        N)r&�get_commandrFr>r>r@r	O�	
zSSHProcess.commandcCr))z�The subsystem the client requested to open, if any

           If the client did not request that a subsystem be opened,
           this property will be set to `None`.

        N)r&�
get_subsystemrFr>r>r@r
[r+zSSHProcess.subsystemcCr))z6A mapping containing the environment set by the clientN)r&�get_environmentrFr>r>r@rgs
zSSHProcess.env�name�defaultcCs|jdusJ�|j�||�S)a5Return additional information about this process

           This method returns extra information about the channel
           associated with this process. See :meth:`get_extra_info()
           <SSHClientChannel.get_extra_info>` on :class:`SSHClientChannel`
           for additional information.

        N)r&r�)r?r.r/r>r>r@r�ns
zSSHProcess.get_extra_info�sourcer��send_eofr�r�c�s6�dtf��fdd�}|tkrd}n�|tkr%�jdusJ��j��d}n�t|t�rI|��\}}	td|�}
t	t
���}|
�|||	�t|
|	�}n�t|t
j�r[t�||��j�j�}n�t|t�rht|d|d�}n0t|t�rwtt|�d|d�}n!t|t�r�tj|d|d�}nt|tj�r�tj|��d|d�}n|}t|d�r�t�|j�s�t�|j�r�t�tt |�|��j�j�}n=t!tt"t#|��r�t$�tt"t#|�|��j�j�}n#t|d	�r�tt%|�j&}�j'dus�J��j'�(||�IdH\}
}tt|�}��)||��t|t$ttf��r|�*�dSt|t��r|
�+|	|�dSdS)
z2Create a reader to forward data to the SSH channelr<c�t���j�j�S)zReturn a pipe read handler)r��	_encoding�_errorsr>�r�r?r>r@�pipe_factory�r�z/SSHProcess._create_reader.<locals>.pipe_factoryNr��rb��	bufferingrA�buffer),r�rrr&rXr�r/�get_redirect_inforr�r�
set_writerr�r�r�r�r3r4rur)rrMr]�fdopen�socket�detachr��inspect�iscoroutinefunctionrA�isgeneratorfunctionr�r9rbr
r|r�rr:�_loop�connect_read_pipe�
set_readerr��
feed_recv_buf)r?r0r�r1r�r�r6r��
reader_stream�reader_datatype�reader_processr�rZ�_�protocolr>r5r@�_create_reader{sh�



�




�
��
�
�
�zSSHProcess._create_reader�targetc�sV�dtf��fdd�}|tkrd}�n|tkrt�}n�|tkr$t��}n�t|t�rH|��\}}	t	d|�}
t
���}|
�|||	�tt
|
|	�}n�t|tj�rZt�||��j�j�}n�d}t|t�rit|d|d�}
n<t|t�rxtt|�d|d�}
n-t|t�r�tj|d||d	�}
nt|tj�r�|r�|��n|��}tj|d||d	�}
n|}
|}t|
d
�r�t�|
j�s�t� |
j�r�t!�t	t"|
�|��j�j�}nRt#t	t$t%|
��r�t&t	t$t%|
�|�j�j�}n:t|d�r�t	t'|�j(}
|s�t�)t	t$t%|
����}tj|ddd�}
�j*du�sJ��j*�+||
�IdH\}}t	t|�}��,||��|�r)��-�|�dSdS)
z4Create a writer to forward data from the SSH channelr<cr2)zReturn a pipe write handler)r�r3r4r>r5r>r@r6�r�z/SSHProcess._create_writer.<locals>.pipe_factoryNr�T�wbr8)r9�closefdrEr:r).r�rrrrrr�r0r;rr�rEr�rr�rr�r3r4rur)rrMr]r=r>r?r_r�r@rArErBr�r9rbr
r|r�rr:�duprC�connect_write_piper<rF)r?rMr�r1r�r�r6r��
writer_stream�writer_datatype�writer_processr�r�rZ�fdrJrKr>r5r@�_create_writer�st�




�


�

�
�
��
�
�zSSHProcess._create_writercs||jvp
t��|�S)z;Return whether output is still being written to the channel)rri�_should_block_drain�r?r�ror>r@rWs

�zSSHProcess._should_block_draincst|j�p	t���S)z0Return whether to pause reading from the channel)r{rri�_should_pause_readingrFror>r@rY	s
�z SSHProcess._should_pause_reading�taskcC�|j�|�dS)z(Add a task to run when the process exitsN)r�append�r?rZr>r>r@r�ryzSSHProcess.add_cleanup_taskrUcsTt��|�t|j���D]}|��q
t|j���D]}|��qi|_i|_dS)z!Handle a close of the SSH channelN)rir��listr�valuesrGr)r?rUr�r�ror>r@r�s


zSSHProcess.connection_lostrCcs0|j�|�}|r|�|�dSt��||�dS)z)Handle incoming data from the SSH channelN)rr�rErir�)r?rCr�r�ror>r@r�"szSSHProcess.data_receivedcs4t|j���D]
\}}|j|r|��qt���S)z3Handle an incoming end of file from the SSH channel)r^r�itemsr�rXrir�)r?r�r�ror>r@r�,s

�
zSSHProcess.eof_receivedc�*t���t|j���D]}|��qdS)z$Pause forwarding data to the channelN)rir�r^rr_rP�r?r�ror>r@r�5�

�zSSHProcess.pause_writingcra)z%Resume forwarding data to the channelN)rir�r^rr_rRrbror>r@r�=rczSSHProcess.resume_writingcCs |jdusJ�|j�||�dS)zFeed data to the channelN)r&rE)r?rCr�r>r>r@r�EszSSHProcess.feed_datacCs>|j|r|jdusJ�|j��|j|��|�|�dS)zFeed EOF to the channelN)rr&rXrrGr�rXr>r>r@r�Ks


zSSHProcess.feed_eofcCs||jvr|�|�dSdS)zFeed pipe close to the channelN)rr�rXr>r>r@r�Us
�zSSHProcess.feed_closer�cCsj|j|D]}t|t�r|�|�q|�|�|jt|�8_q|j|��|jr/|�	�|�
�dS)z1Feed current receive buffer to a newly set writerN)�	_recv_bufr�rYrWrE�
_recv_buf_len�len�clear�
_eof_receivedrX�_maybe_resume_reading)r?r�r��bufr>r>r@rF[s

zSSHProcess.feed_recv_bufcC�|j�|�|��dS)z#Pause feeding data from the channelN)r�add�_maybe_pause_readingrXr>r>r@r�m�zSSHProcess.pause_feedingcCrk)z$Resume feeding data from the channelN)r�removerirXr>r>r@r�srnzSSHProcess.resume_feedingr�cCs\|j�|�}|r|��|r#||j|<||j|<|jr!|��dSdS|r,|�|�dSdS)z0Set a reader used to forward data to the channelN)rr�rGr�
_write_pausedrPr�)r?r�r1r��
old_readerr>r>r@rEys

��zSSHProcess.set_readercCs|j|=|j|=|�|�dS)z-Clear a reader forwarding data to the channelN)rr�_unblock_drainrXr>r>r@r��szSSHProcess.clear_readercCsB|j�|�}|r|��|�|�|r||j|<||j|<dSdS)z2Set a writer used to forward data from the channelN)rr�rGr�r�)r?r�r�r��
old_writerr>r>r@r<�s

�zSSHProcess.set_writercCs ||jvr
|�|�|j|=dS)z/Clear a writer forwarding data from the channelN)rr�rrXr>r>r@r��s

zSSHProcess.clear_writercCr�)zShut down the processN)r&rGrFr>r>r@rG�r�zSSHProcess.closecCr))z-Return if the channel is closing or is closedN)r&�
is_closingrFr>r>r@rt�s
zSSHProcess.is_closingc�s@�|jdusJ�|j��IdH|jD]}|IdHqg|_dS)z,Wait for the process to finish shutting downN)r&r#rr]r>r>r@r#�s�

zSSHProcess.wait_closedrHrh):rIrJrKrLrjrrrr�
BaseExceptionrr{r$�propertyrrr�r!r(rur	r
rrrr��
ProcessSourcerMr.rL�
ProcessTargetrVrWrYr	r�rYr�r�r�r�r�r�r�r�rTrFr�r�rNrEr�r<r�rGrtr#r}r>r>ror@r#s�
��
�	����
�C����
�G
	
�
�
��
���
�
rcsTeZdZUdZeeed<eeed<dH�fdd�ZdIdedefd	d
�Z	dHdd�Z
edee
fd
d��Zedeeeeeeffdd��Zedee
fdd��Zedeefdd��Zedeefdd��Zedeefdd��Zdeddfdd�Zdddejddfdeedeedeed e
d!ed"eddfd#d$�Zejdfd%ed e
d!eddfd&d'�Z ejdfd(ed e
d"eddfd)d*�Z!ejdfd(ed e
d"eddfd+d,�Z"deeeffd-d.�Z#dId/eedeeeffd0d1�Z$	2dJd3e
d4e
d5e
d6e
ddf
d7d8�Z%d9e
ddfd:d;�Z&d<eddfd=d>�Z'dHd?d@�Z(dHdAdB�Z)	C	dKdDedEee*de+fdFdG�Z,�Z-S)Lr�zSSH client process handlerr&r�r<Ncs t���d|_d|_d|_dSrh)rirj�_stdin�_stdout�_stderrrFror>r@rj�s

zSSHClientProcess.__init__r�cCsp|j|}|rt|dt�r|dd�|dd�}|j|<ng|j|<tt|jr+dnd�}|�ttt|��S)zReturn output from the processr:Nrrw)rdr�rYrrr3r�r)r?r��recv_bufrjr>r>r@�_collect_output�s
"
z SSHClientProcess._collect_outputcCs<tt||j�|_tt||j�|_tt||jt�|_dS)z4Start a process for this newly opened client channelN)r0rr&ryr/rzr r{rFr>r>r@�session_started�sz SSHClientProcess.session_startedcC�
|j��S)zThe exit status of the process)r&�get_exit_statusrFr>r>r@r��
zSSHClientProcess.exit_statuscCr)z'Exit signal information for the process)r&�get_exit_signalrFr>r>r@r�r�zSSHClientProcess.exit_signalcCr)z>The exit status or negative exit signal number for the process)r&�get_returncoderFr>r>r@r
�r�zSSHClientProcess.returncodecCr%)z>The :class:`SSHWriter` to use to write to stdin of the processN�ryrFr>r>r@�stdin�r'zSSHClientProcess.stdincCr%)z@The :class:`SSHReader` to use to read from stdout of the processN�rzrFr>r>r@r�r'zSSHClientProcess.stdoutcCr%)z@The :class:`SSHReader` to use to read from stderr of the processN�r{rFr>r>r@rr'zSSHClientProcess.stderrrUcCsdt|t�r|j�|j|j|j|j�dSt|t�r"|j�	|j
�dSt|t�r0|j�|j
�dSdS)zFeed exception to the channelN)r�r-r&�change_terminal_size�width�height�pixwidth�	pixheightr+�
send_break�msecr,�send_signalrrVr>r>r@r�s
�

�zSSHClientProcess.feed_exceptionTr�rrr�r1r�c��Z�|r|�||||�IdH|r|�||||�IdH|r+|�||||t�IdHdSdS)a�
Perform I/O redirection for the process

           This method redirects data going to or from any or all of
           standard input, standard output, and standard error for
           the process.

           The `stdin` argument can be any of the following:

               * An :class:`SSHReader` object
               * An :class:`asyncio.StreamReader` object
               * A file object open for read
               * An `int` file descriptor open for read
               * A connected socket object
               * A string or :class:`PurePath <pathlib.PurePath>` containing
                 the name of a file or device to open
               * `DEVNULL` to provide no input to standard input
               * `PIPE` to interactively write standard input

           The `stdout` and `stderr` arguments can be any of the following:

               * An :class:`SSHWriter` object
               * An :class:`asyncio.StreamWriter` object
               * A file object open for write
               * An `int` file descriptor open for write
               * A connected socket object
               * A string or :class:`PurePath <pathlib.PurePath>` containing
                 the name of a file or device to open
               * `DEVNULL` to discard standard error output
               * `PIPE` to interactively read standard error output

           The `stderr` argument also accepts the value `STDOUT` to
           request that standard error output be delivered to stdout.

           File objects passed in can be associated with plain files, pipes,
           sockets, or ttys.

           The default value of `None` means to not change redirection
           for that stream.

           .. note:: While it is legal to use buffered I/O streams such
                     as sys.stdin, sys.stdout, and sys.stderr as redirect
                     targets, you must make sure buffers are flushed
                     before redirection begins and that these streams
                     are put back into blocking mode before attempting
                     to go back using buffered I/O again. Also, no buffered
                     I/O should be performed while redirection is active.

           .. note:: When passing in asyncio streams, it is the responsibility
                     of the caller to close the associated transport when it
                     is no longer needed.

           :param stdin:
               Source of data to feed to standard input
           :param stdout:
               Target to feed data from standard output to
           :param stderr:
               Target to feed data from standard error to
           :param bufsize:
               Buffer size to use when forwarding data from a file
           :param send_eof:
               Whether or not to send EOF to the channel when EOF is
               received from stdin, defaulting to `True`. If set to `False`,
               the channel will remain open after EOF is received on stdin,
               and multiple sources can be redirected to the channel.
           :param recv_eof:
               Whether or not to send EOF to stdout and stderr when EOF is
               received from the channel, defaulting to `True`. If set to
               `False`, the redirect targets of stdout and stderr will remain
               open after EOF is received on the channel and can be used for
               multiple redirects.
           :type bufsize: `int`
           :type send_eof: `bool`
           :type recv_eof: `bool`

        N)rLrVr �r?r�rrr�r1r�r>r>r@�redirects�Q��zSSHClientProcess.redirectr0c�s �|�|dd||d�IdHdS�z&Redirect standard input of the processNT�r��r?r0r�r1r>r>r@�redirect_stdinn��zSSHClientProcess.redirect_stdinrMc�s �|�d|d|d|�IdHdS�z'Redirect standard output of the processNTr��r?rMr�r�r>r>r@�redirect_stdoutur�z SSHClientProcess.redirect_stdoutc�s �|�dd||d|�IdHdS�z&Redirect standard error of the processNTr�r�r>r>r@�redirect_stderr|r�z SSHClientProcess.redirect_stderrcCs|��|�t�fS)a�Collect output from the process without blocking

           This method returns a tuple of the output that the process
           has written to stdout and stderr which has not yet been read.
           It is intended to be called instead of read() by callers
           that want to collect received data without blocking.

           :returns: A tuple of output to stdout and stderr

        )r}r rFr>r>r@�collect_output�s�zSSHClientProcess.collect_output�inputc�s@�d|_|��|r|j�|�|j��|��IdH|��S)aSend input to and/or collect output from the process

           This method is a coroutine which optionally provides input
           to the process and then waits for the process to exit,
           returning a tuple of the data written to stdout and stderr.

           :param input:
               Input data to feed to standard input of the process. Data
               should be a `str` if encoding is set, or `bytes` if not.
           :type input: `str` or `bytes`

           :returns: A tuple of output to stdout and stderr

        rN)�_limitrir&rErXr#r�)r?r�r>r>r@�communicate�s�
zSSHClientProcess.communicaterr�r�r�r�cCs|j�||||�dS)a�Change the terminal window size for this process

           This method changes the width and height of the terminal
           associated with this process.

           :param width:
               The width of the terminal in characters
           :param height:
               The height of the terminal in characters
           :param pixwidth: (optional)
               The width of the terminal in pixels
           :param pixheight: (optional)
               The height of the terminal in pixels
           :type width: `int`
           :type height: `int`
           :type pixwidth: `int`
           :type pixheight: `int`

           :raises: :exc:`OSError` if the SSH channel is not open

        N)r&r�)r?r�r�r�r�r>r>r@r��sz%SSHClientProcess.change_terminal_sizer�cCr[)z�Send a break to the process

           :param msec:
               The duration of the break in milliseconds
           :type msec: `int`

           :raises: :exc:`OSError` if the SSH channel is not open

        N)r&r�)r?r�r>r>r@r���zSSHClientProcess.send_breakrcCr[)z�Send a signal to the process

           :param signal:
               The signal to deliver
           :type signal: `str`

           :raises: :exc:`OSError` if the SSH channel is not open

        N)r&r�)r?rr>r>r@r��r�zSSHClientProcess.send_signalcCr�)zbTerminate the process

           :raises: :exc:`OSError` if the SSH channel is not open

        N)r&�	terminaterFr>r>r@r���zSSHClientProcess.terminatecCr�)zfForcibly kill the process

           :raises: :exc:`OSError` if the SSH channel is not open

        N)r&�killrFr>r>r@r��r�zSSHClientProcess.killF�check�timeoutc�s��zt�|��|�IdH\}}Wn tjy0|��\}}t|j|j|j|j|j	|j
||�d�w|rG|jrGt|j|j|j|j|j	|j
||��t|j|j|j|j|j	|j
||�S)a2Wait for process to exit

           This method is a coroutine which waits for the process to
           exit. It returns an :class:`SSHCompletedProcess` object with
           the exit status or signal information and the output sent
           to stdout and stderr if those are redirected to pipes.

           If the check argument is set to `True`, a non-zero exit
           status from the process with trigger the :exc:`ProcessError`
           exception to be raised.

           If a timeout is specified and it expires before the process
           exits, the :exc:`TimeoutError` exception will be raised. By
           default, no timeout is set and this call will wait indefinitely.

           :param check:
               Whether or not to raise an error on non-zero exit status
           :param timeout:
               Amount of time in seconds to wait for process to exit, or
               `None` to wait indefinitely
           :type check: `bool`
           :type timeout: `int`, `float`, or `None`

           :returns: :class:`SSHCompletedProcess`

           :raises: | :exc:`ProcessError` if check is set to `True`
                      and the process returns a non-zero exit status
                    | :exc:`TimeoutError` if the timeout expires
                      before the process exits

        N)
r��wait_forr�rr�rr	r
rrr
rr)r?r�r��stdout_data�stderr_datar>r>r@r��s0�"
����
��zSSHClientProcess.waitrHrh)rr)FN).rIrJrKrLrrrrjr.r}r~rvrrMrrrur{rr
r0r�r/rrrYr��io�DEFAULT_BUFFER_SIZErwrxr�r�r�r�r�r�r�r�r�r�r��floatrr�r}r>r>ror@r��s�


 ������
�\���
����
����
�

����
�

		���r�cs.eZdZUdZeeed<eeed<dedee	de
def�fdd	�Zd
e
edeedeed
edfdd�Zed
eefdd��Zed
efdd��Zed
efdd��Zed
e
efdd��Zed
eefdd��Zed
eefdd��Zded
df�fdd�Zdddejd d fd
eedee dee d!e
d"ed#ed
dfd$d%�Z!ejd fd&ed!e
d#ed
dfd'd(�Z"ejd fd)e d!e
d"ed
dfd*d+�Z#ejd fd)e d!e
d"ed
dfd,d-�Z$d
eefd.d/�Z%d
e&e
e
e
e
ffd0d1�Z'd2e
d
ee
fd3d4�Z(d5e
d
dfd6d7�Z)d8d9e*fd:ed;ed<ed=ed
df
d>d?�Z+�Z,S)@r�zSSH server process handlerr&r��process_factory�sftp_factory�sftp_version�	allow_scpcs0t��|j|||�||_d|_d|_d|_dSrh)rirj�_start_process�_process_factoryryrzr{)r?r�r�r�r�ror>r@rj4s�
zSSHServerProcess.__init__r�rrr<NcCs||_||_||_|�|�S)zStart a new server process)ryrzr{r�)r?r�rrr>r>r@r�@s
zSSHServerProcess._start_processcCr)z�The terminal type set by the client

           If the client didn't request a pseudo-terminal, this
           property will be set to `None`.

        )r&�get_terminal_typerFr>r>r@�	term_typeK�
	zSSHServerProcess.term_typecCr)aiThe terminal size set by the client

           This property contains a tuple of four `int` values
           representing the width and height of the terminal in
           characters followed by the width and height of the
           terminal in pixels. If the client hasn't set terminal
           size information, the values will be set to zero.

        )r&�get_terminal_sizerFr>r>r@r�Vs
zSSHServerProcess.term_sizecCr)z�A mapping containing the TTY modes set by the client

           If the client didn't request a pseudo-terminal, this
           property will be set to an empty mapping.

        )r&�get_terminal_modesrFr>r>r@�
term_modesdr�zSSHServerProcess.term_modescCr%)z?The :class:`SSHReader` to use to read from stdin of the processNr�rFr>r>r@r�or'zSSHServerProcess.stdincCr%)z?The :class:`SSHWriter` to use to write to stdout of the processNr�rFr>r>r@rvr'zSSHServerProcess.stdoutcCr%)z?The :class:`SSHWriter` to use to write to stderr of the processNr�rFr>r>r@r}r'zSSHServerProcess.stderrrUcs.|j�d�}|r|�|�dSt��|�dS)z+Handle an incoming exception on the channelN)rr�rWri�exception_received)r?rUr�ror>r@r��sz#SSHServerProcess.exception_receivedTr�r1r�c�r�)a^Perform I/O redirection for the process

           This method redirects data going to or from any or all of
           standard input, standard output, and standard error for
           the process.

           The `stdin` argument can be any of the following:

               * An :class:`SSHWriter` object
               * An :class:`asyncio.StreamWriter` object
               * A file object open for write
               * An `int` file descriptor open for write
               * A connected socket object
               * A string or :class:`PurePath <pathlib.PurePath>` containing
                 the name of a file or device to open
               * `DEVNULL` to discard standard error output
               * `PIPE` to interactively read standard error output

           The `stdout` and `stderr` arguments can be any of the following:

               * An :class:`SSHReader` object
               * An :class:`asyncio.StreamReader` object
               * A file object open for read
               * An `int` file descriptor open for read
               * A connected socket object
               * A string or :class:`PurePath <pathlib.PurePath>` containing
                 the name of a file or device to open
               * `DEVNULL` to provide no input to standard input
               * `PIPE` to interactively write standard input

           File objects passed in can be associated with plain files, pipes,
           sockets, or ttys.

           The default value of `None` means to not change redirection
           for that stream.

           .. note:: When passing in asyncio streams, it is the responsibility
                     of the caller to close the associated transport when it
                     is no longer needed.

           :param stdin:
               Target to feed data from standard input to
           :param stdout:
               Source of data to feed to standard output
           :param stderr:
               Source of data to feed to standard error
           :param bufsize:
               Buffer size to use when forwarding data from a file
           :param send_eof:
               Whether or not to send EOF to the channel when EOF is
               received from stdout or stderr, defaulting to `True`. If
               set to `False`, the channel will remain open after EOF is
               received on stdout or stderr, and multiple sources can be
               redirected to the channel.
           :param recv_eof:
               Whether or not to send EOF to stdin when EOF is received
               on the channel, defaulting to `True`. If set to `False`,
               the redirect target of stdin will remain open after EOF
               is received on the channel and can be used for multiple
               redirects.
           :type bufsize: `int`
           :type send_eof: `bool`
           :type recv_eof: `bool`

        N)rVrLr r�r>r>r@r��s�G��zSSHServerProcess.redirectrMc�s �|�|dd|d|�IdHdSr�r�r�r>r>r@r��r�zSSHServerProcess.redirect_stdinr0c�s �|�d|d||d�IdHdSr�r�r�r>r>r@r��r�z SSHServerProcess.redirect_stdoutc�s �|�dd|||d�IdHdSr�r�r�r>r>r@r��r�z SSHServerProcess.redirect_stderrcC�|jS)a�Return the terminal type set by the client for the process

           This method returns the terminal type set by the client
           when the process was started. If the client didn't request
           a pseudo-terminal, this method will return `None`.

           :returns: A `str` containing the terminal type or `None` if
                     no pseudo-terminal was requested

        )r�rFr>r>r@r��sz"SSHServerProcess.get_terminal_typecCr�)a�Return the terminal size set by the client for the process

           This method returns the latest terminal size information set
           by the client. If the client didn't set any terminal size
           information, all values returned will be zero.

           :returns: A tuple of four `int` values containing the width and
                     height of the terminal in characters and the width
                     and height of the terminal in pixels

        )r�rFr>r>r@r�s
z"SSHServerProcess.get_terminal_size�modecCs|j�|�S)a�Return the requested TTY mode for this session

           This method looks up the value of a POSIX terminal mode
           set by the client when the process was started. If the client
           didn't request a pseudo-terminal or didn't set the requested
           TTY mode opcode, this method will return `None`.

           :param mode:
               POSIX terminal mode taken from :ref:`POSIX terminal modes
               <PTYModes>` to look up
           :type mode: `int`

           :returns: An `int` containing the value of the requested
                     POSIX terminal mode or `None` if the requested
                     mode was not set

        )r�r�)r?r�r>r>r@�get_terminal_modesz"SSHServerProcess.get_terminal_mode�statuscCr[)a%Send exit status and close the channel

           This method can be called to report an exit status for the
           process back to the client and close the channel.

           :param status:
               The exit status to report to the client
           :type status: `int`

        N)r&�exit)r?r�r>r>r@r�&szSSHServerProcess.exitFrrrrrcCs|j�||||�S)aGSend exit signal and close the channel

           This method can be called to report that the process
           terminated abnormslly with a signal. A more detailed
           error message may also provided, along with an indication
           of whether or not the process dumped core. After
           reporting the signal, the channel is closed.

           :param signal:
               The signal which caused the process to exit
           :param core_dumped: (optional)
               Whether or not the process dumped core
           :param msg: (optional)
               Details about what error occurred
           :param lang: (optional)
               The language the error message is in
           :type signal: `str`
           :type core_dumped: `bool`
           :type msg: `str`
           :type lang: `str`

        )r&�exit_with_signal)r?rrrrr>r>r@r�4sz!SSHServerProcess.exit_with_signal)-rIrJrKrLrrr�SSHServerProcessFactoryrr4rMr{rjr/r0r$r�rvrur�r&r�r%r�r�rrrYr�r�r�rxrwr�r�r�r�r�rr�r�r�rr�r}r>r>ror@r�.s�
���
��
�



������
�R���
����
����
�����r�)krLr��asyncio.subprocessrrrrkr@r�r]�pathlibrr>r[�typesr�typingrrr	r
rrr
rrrrrrrrrrr�typing_extensionsrrr�rrr�	constantsrr �loggingr!�miscr"r#r$r%r&r'r(r)r*r+r,r-�sessionr.�streamr/r0r1r2r3r4r|rur5�_FilerMr�rwrrxr�r�r�r9rNrTr{rbrcr~r�r�r�r��BaseProtocolr�r�r�r�r�r�rrrrrrr�r�r>r>r>r@�<module>s�$ ���

#,3<4A1=
@- p