%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/paramiko/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/paramiko/__pycache__/sftp_server.cpython-312.pyc

�

�ec�L��j�dZddlZddlZddlZddlmZmZddlmZddl	m
Z
mZmZm
Z
mZddlmZddlmZddlmZdd	lmZmZmZmZdd
lmZddl	mZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@eed�ZAGd
�de
e�ZBddlCmDZDy)z
Server-mode SFTP support.
�N)�md5�sha1)�util)�BaseSFTP�Message�SFTP_FAILURE�SFTP_PERMISSION_DENIED�SFTP_NO_SUCH_FILE)�SFTPServerInterface)�SFTPAttributes)�DEBUG)�long�string_types�bytes_types�b)�SubsystemHandler)%�
CMD_HANDLE�	SFTP_DESC�
CMD_STATUS�SFTP_EOF�CMD_NAME�SFTP_BAD_MESSAGE�CMD_EXTENDED_REPLY�SFTP_FLAG_READ�SFTP_FLAG_WRITE�SFTP_FLAG_APPEND�SFTP_FLAG_CREATE�SFTP_FLAG_TRUNC�SFTP_FLAG_EXCL�	CMD_NAMES�CMD_OPEN�	CMD_CLOSE�SFTP_OK�CMD_READ�CMD_DATA�	CMD_WRITE�
CMD_REMOVE�
CMD_RENAME�	CMD_MKDIR�	CMD_RMDIR�CMD_OPENDIR�CMD_READDIR�CMD_STAT�	CMD_ATTRS�	CMD_LSTAT�	CMD_FSTAT�CMD_SETSTAT�CMD_FSETSTAT�CMD_READLINK�CMD_SYMLINK�CMD_REALPATH�CMD_EXTENDED�SFTP_OP_UNSUPPORTED)rrc���eZdZdZefd�Z�fd�Zd�Z�fd�Ze	d��Z
e	d��Zd�Zdd	�Z
dd
�Zd�Zd�Zd
�Zd�Zd�Z�xZS)�
SFTPServerz�
    Server-side SFTP subsystem support.  Since this is a `.SubsystemHandler`,
    it can be (and is meant to be) set as the handler for ``"sftp"`` requests.
    Use `.Transport.set_subsystem_handler` to activate this class.
    c�J�tj|�tj||||�|j�}t	j
|j
�dz�|_|j�|_	d|_
i|_i|_||g|��i|��|_
y)a�
        The constructor for SFTPServer is meant to be called from within the
        `.Transport` as a subsystem handler.  ``server`` and any additional
        parameters or keyword parameters are passed from the original call to
        `.Transport.set_subsystem_handler`.

        :param .Channel channel: channel passed from the `.Transport`.
        :param str name: name of the requested subsystem.
        :param .ServerInterface server:
            the server object associated with this channel and subsystem
        :param sftp_si:
            a subclass of `.SFTPServerInterface` to use for handling individual
            requests.
        z.sftp�N)r�__init__r�
get_transportr�
get_logger�get_log_channel�logger�get_hexdump�ultra_debug�next_handle�
file_table�folder_table�server)�self�channel�namerF�sftp_si�largs�kwargs�	transports        �6/usr/lib/python3/dist-packages/paramiko/sftp_server.pyr<zSFTPServer.__init__^s���.	���$���!�!�$���v�>��)�)�+�	��o�o�i�&?�&?�&A�G�&K�L���$�0�0�2�������������f�7�u�7��7���c���tt|�t�r=|D]7}tt|�|d|jj�zdz|z��9ytt|�|d|jj�zdz|z�y)Nz[chan z] )�
issubclass�type�list�superr9�_log�sock�get_name)rG�level�msg�m�	__class__s    �rNrUzSFTPServer._log�s�����d�3�i��&��
���j�$�,��8�d�i�i�&8�&8�&:�:�T�A�A�E��
�

�*�d�(��x�$�)�)�"4�"4�"6�6��=��C�
rOc�6�||_|jtdj|��|j	�|j
j
�		|j�\}}t|�}|j�}	|j|||��D#t$r|jtd�Yyt$rT}|jtdt|�z�|jttj��Yd}~yd}~wwxYw#t$rs}|jtdt|�z�|jttj��	|j!|t"�n#YnxYwYd}~��d}~wwxYw)Nz#Started sftp server on channel {!r}zEOF -- end of sessionzException on channel: z Exception in server processing: )rVrUr
�format�_send_server_versionrF�session_started�_read_packet�EOFError�	Exception�strr�
tb_stringsr�get_int�_process�_send_statusr)	rGrIrMrH�t�data�erY�request_numbers	         rN�start_subsystemzSFTPServer.start_subsystem�sB����	��	�	�%�>�E�E�g�N�O��!�!�#����#�#�%��
��+�+�-���4��$�-�C� �[�[�]�N�	
��
�
�a���5����
��	�	�%�!8�9���
��	�	�%�!9�C��F�!B�C��	�	�%����!2�3���
���
��	�	�%�!C�c�!�f�!L�M��	�	�%����!2�3���%�%�n�l�C������
�sP�B�D�D�=D�A
D�D�	F�%A
F�0F�F�F�	F�Fc�6��|jj�tt|��|j
j
�D]}|j��|jj
�D]}|j��i|_i|_y�N)	rF�
session_endedrTr9�finish_subsystemrD�values�closerE)rG�fr[s  �rNrpzSFTPServer.finish_subsystem�s}������!�!�#�
�j�$�0�2����'�'�)�	�A�
�G�G�I�	��"�"�)�)�+�	�A�
�G�G�I�	������rOc��|tjk(rtS|tjk(s|tjk(rt
StS)au
        Convert an errno value (as from an ``OSError`` or ``IOError``) into a
        standard SFTP result code.  This is a convenience function for trapping
        exceptions in server code and returning an appropriate result.

        :param int e: an errno code, as from ``OSError.errno``.
        :return: an `int` SFTP error code like ``SFTP_NO_SUCH_FILE``.
        )�errno�EACCESr	�ENOENT�ENOTDIRr
r)rjs rN�
convert_errnozSFTPServer.convert_errno�s9��
�����)�)��5�<�<��Q�%�-�-�%7�$�$��rOc�Z�tjdk7r}|j|jzr t	j
||j�|j|jzr+t	j||j|j�|j|jzr,t	j||j|jf�|j|jzr1t!|d�5}|j#|j$�ddd�yy#1swYyxYw)a:
        Change a file's attributes on the local filesystem.  The contents of
        ``attr`` are used to change the permissions, owner, group ownership,
        and/or modification & access time of the file, depending on which
        attributes are present in ``attr``.

        This is meant to be a handy helper function for translating SFTP file
        requests into local file operations.

        :param str filename:
            name of the file to alter (should usually be an absolute path).
        :param .SFTPAttributes attr: attributes to change.
        �win32zw+N)�sys�platform�_flags�FLAG_PERMISSIONS�os�chmod�st_mode�FLAG_UIDGID�chown�st_uid�st_gid�FLAG_AMTIME�utime�st_atime�st_mtime�	FLAG_SIZE�open�truncate�st_size)�filename�attrrss   rN�
set_file_attrzSFTPServer.set_file_attr�s����<�<�7�"��{�{�T�2�2�2�����4�<�<�0��{�{�T�-�-�-�����4�;�;����<��;�;��)�)�)��H�H�X��
�
�t�}�}�=�>��;�;����'��h��%�
)���
�
�4�<�<�(�
)�
)�(�
)�
)�s�;D!�!D*c	���t�}|j|�|D]�}t|t�r|j	|��%t|t
�r|j|��Gt|ttf�r|j|��ot|�tur|j|���tdj|t|����|j||�y)Nzunknown type for {!r} type {!r})r�add_int�
isinstancer�	add_int64�intrr�
add_stringrRr�_packrbr]�_send_packet)rGrkrh�argrY�items      rN�	_responsezSFTPServer._response�s����i�����N�#��	�D��$��%��
�
�d�#��D�#�&����D�!��D�<��"=�>����t�$��d��~�-��
�
�3���5�<�<�T�4��:�N���	�	
���!�S�!rOc��tt|�t�s|j||�y|j	tdj
|j���|xjdz
c_|r||j|j�<n||j|j�<|j|t|j��y)Nzhx{:d}r;)
rQrR�
SFTPHandlerg�	_set_namerr]rCrE�	_get_namerDr�r)rGrk�handle�folders    rN�_send_handle_responsez SFTPServer._send_handle_response�s����$�v�,�
�3����n�f�5������8�?�?�4�+;�+;�<�=�>����A����4:�D���f�.�.�0�1�28�D�O�O�F�,�,�.�/����~�z�6�3C�3C�3E�FrOc�p�|�
	t|}|j|t||d�y#t$rd}Y�'wxYw)N�Unknown�)r�
IndexErrorr�r)rGrk�code�descs    rNrgzSFTPServer._send_statussA���<�
!� ����
	
���~�z�4��r�B��	�
!� ��
!�s�	'�5�5c���|jj|�}tt|�t�r/t�}|j
|�|j||d�y|j||�y)NT)	rF�list_folderrQrRrSr��
_set_filesr�rg)rGrk�path�respr�s     rN�_open_folderzSFTPServer._open_folders^���{�{�&�&�t�,���d�4�j�$�'��\�F����d�#��&�&�~�v�t�D�����.�$�/rOc��|j�}t|�dk(r|j|t�yt	�}|j|�|jt|��|D]?}|j
|j�|j
|�|j|��A|jt|�y)Nr)�_get_next_files�lenrgrrr�r�r�r�r�r)rGrkr��flistrYr�s      rN�_read_folderzSFTPServer._read_folders����&�&�(���u�:��?����n�h�7���i�����N�#����C��J���	�D��N�N�4�=�=�)��N�N�4� ��J�J�s�O�	�	
���(�C�(rOc��|j�}|j�}|j�}|j�}|j�}||jvr|j|td�y|j|}|D]}	|	tvs�|	}
t|	}n|j|td�y|dk(rL|j�}tt|�t�s|j||d�y|j|z
}|dk(r|}|dkr|j|td�yt�}
|}|||zkr�t|||z|z
�}t|d�}d}|�}||kr`|j!||�}t#|t$�s|j||d�y|j'|�|t)|�z
}||z
}||kr�`|
|j+�z
}
|||zkr��t-�}|j/|�|j1d	�|j1|
�|j3|
�|j5t6|�y)
N�Invalid handlezNo supported hash types foundrzUnable to stat file�zBlock size too smallizUnable to hash file�
check-file)�
get_binary�get_list�	get_int64rerDrgr�_hash_classr�statrQrRrr��bytes�min�readr�r�updater��digestrr�r��	add_bytesr�r)rGrkrYr��alg_list�start�length�
block_sizers�x�algname�alg�st�sum_out�offset�blocklen�chunklen�count�hash_objris                    rN�_check_filezSFTPServer._check_file%sD��
���!���<�<�>���
�
���������[�[�]�
�����(����� 0�2B�
�
��O�O�F�#���		�A��K����!�!�n���			�
�����.M�
�
��Q�;�����B��d�2�h��7��!�!�.�"�6K�L���Z�Z�%�'�F���?��J���������.D�
�
��'�����u�v�~�%��:�u�v�~��'>�?�H��8�U�+�H��E��u�H��(�"��v�v�f�h�/��!�$��4��%�%�&��.C�������%���T��"���%����(�"�
�x���(�(�G�!�u�v�~�%�$�i�����N�#����|�$����w���
�
�g�����,�c�2rOc��|tzr|tzrtj}n*|tzrtj}ntj
}|tzr|tjz}|tzr|tjz}|tzr|tjz}|tzr|tjz}|S)z;convert SFTP-style open() flags to Python's os.open() flags)rrr��O_RDWR�O_WRONLY�O_RDONLYr�O_APPENDr�O_CREATr�O_TRUNCr�O_EXCL)rG�pflags�flagss   rN�_convert_pflagszSFTPServer._convert_pflagshs����^�#�&�?�*B��I�I�E�
�o�
%��K�K�E��K�K�E��$�$��R�[�[� �E��$�$��R�Z�Z��E��O�#��R�Z�Z��E��N�"��R�Y�Y��E��rOc	���|jtdjt|��|tk(rr|j�}|j
|j��}tj|�}|j||jj|||��y|tk(r�|j�}||jvr$|j|=|j!|t"�y||j$vrA|j$|j'�|j$|=|j!|t"�y|j!|t(d�y|t*k(r�|j�}|j-�}|j�}	||j$vr|j!|t(d�y|j$|j/||	�}
t1|
t2t4f�r=t7|
�dk(r|j!|t8�y|j;|t<|
�y|j!||
�y|t>k(r�|j�}|j-�}|j�}
||j$vr|j!|t(d�y|j!||j$|jA||
��y|tBk(r<|j�}|j!||jjE|��y|tFk(rM|j�}|j�}|j!||jjI||��y|tJk(rR|j�}tj|�}|j!||jjM||��y|tNk(r<|j�}|j!||jjQ|��y|tRk(r#|j�}|jU||�y|tVk(rX|j�}||jvr|j!|t(d�y|j|}
|jY||
�y|tZk(ro|j�}|jj]|�}t_ta|�t�r|j;|tb|�y|j!||�y|tdk(ro|j�}|jjg|�}t_ta|�t�r|j;|tb|�y|j!||�y|thk(r�|j�}||j$vr|j!|t(d�y|j$|j]�}t_ta|�t�r|j;|tb|�y|j!||�y|tjk(rR|j�}tj|�}|j!||jjm||��y|tnk(rz|j�}tj|�}||j$vr|j;|t(d�y|j!||j$|jm|��y|tpk(rw|j�}|jjs|�}t1|t2t4f�r#|j;|ttd|dt��y|j!||�y|tvk(rM|j�}|j�}|j!||jjy||��y|tzk(rN|j�}|jj}|�}|j;|ttd|dt��y|t~k(r�|j�}|dk(r|j�||�y|dk(rM|j�}|j�}|j!||jj�||��y|j!|t��y|j!|t��y)NzRequest: {}r�rr;r�r�zposix-rename@openssh.com)CrUr
r]r r!�get_textr�rer�	_from_msgr�rFr�r"r�rErgr#rDrrrr$r�r�r�rrr�rr�r%r&�writer'�remover(�renamer)�mkdirr*�rmdirr+r�r,r�r-r�rQrRr.r/�lstatr0r1�chattrr2r3�readlinkrr4�symlinkr5�canonicalizer6r��posix_renamer7)rGrhrkrYr�r�r�r�r�r�ri�oldpath�newpathr�r��target_path�rpath�tags                  rNrfzSFTPServer._processzs���	�	�%��-�-�i��l�;�<���=��<�<�>�D��(�(�����7�E�!�+�+�C�0�D��&�&����� 0� 0��u�d� C�
��)�^��^�^�%�F���*�*�*��%�%�f�-��!�!�.�'�:������(�����'�-�-�/��O�O�F�+��!�!�.�'�:������ 0�2B�
��(�]��^�^�%�F��]�]�_�F��[�[�]�F��T�_�_�,��!�!�"�$4�6F����?�?�6�*�/�/���?�D��$��l� ;�<��t�9��>��%�%�n�h�?��N�N�>�8�T�B��!�!�.�$�7�
�)�^��^�^�%�F��]�]�_�F��>�>�#�D��T�_�_�,��!�!�"�$4�6F����������� 7� =� =�f�d� K�
��*�_��<�<�>�D����n�d�k�k�.@�.@��.F�G�
�*�_��l�l�n�G��l�l�n�G�������� 2� 2�7�G� D�
��)�^��<�<�>�D�!�+�+�C�0�D����n�d�k�k�.?�.?��d�.K�L�
�)�^��<�<�>�D����n�d�k�k�.?�.?��.E�F�
�+�
��<�<�>�D����n�d�3��
�+�
��^�^�%�F��T�.�.�.��!�!�"�$4�6F����&�&�v�.�F����n�f�5�
�(�]��<�<�>�D��;�;�#�#�D�)�D��$�t�*�n�5����~�y�$�?��!�!�.�$�7�
�)�^��<�<�>�D��;�;�$�$�T�*�D��$�t�*�n�5����~�y�$�?��!�!�.�$�7�
�)�^��^�^�%�F��T�_�_�,��!�!�"�$4�6F����?�?�6�*�/�/�1�D��$�t�*�n�5����~�y�$�?��!�!�.�$�7�
�+�
��<�<�>�D�!�+�+�C�0�D����n�d�k�k�.@�.@��t�.L�M�
�,�
��^�^�%�F�!�+�+�C�0�D��T�_�_�,����"�$4�6F����������� 7� >� >�t� D�
��,�
��<�<�>�D��;�;�'�'��-�D��$��l� ;�<����"�H�a��r�>�;K���!�!�.�$�7�
�+�
��,�,�.�K��<�<�>�D�������� 3� 3�K�� F�
��,�
��<�<�>�D��K�K�,�,�T�2�E��N�N���!�U�B��8H�
��,�
��,�,�.�C��l�"�� � ���5��2�2��,�,�.���,�,�.���!�!�"�D�K�K�$<�$<�W�g�$N���!�!�.�2E�F����n�.A�BrO)Frn)�__name__�
__module__�__qualname__�__doc__rr<rUrlrp�staticmethodryr�r�r�rgr�r�r�r�rf�
__classcell__)r[s@rNr9r9Wsx����$� 8�D	��8
�� �� �$�)��)�8"�$G�C�	0�)�A3�F�$^CrOr9)r�)Er�r�rur|�hashlibrr�paramikor�
paramiko.sftprrrr	r
�paramiko.sftp_sir�paramiko.sftp_attrr�paramiko.commonr
�paramiko.py3compatrrrr�paramiko.serverrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r�r9�paramiko.sftp_handler��rOrN�<module>rs���&�
��
�����1�-�!�A�A�,�&�&�&�&�&�&�&�&�&�&�P�C�(��AC��+�AC�H,rO

Zerion Mini Shell 1.0