%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/duplicity/backends/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/duplicity/backends/__pycache__/ssh_pexpect_backend.cpython-312.pyc

�

�2e�2��<�ddlZddlZddlZddlmZddlmZddlmZGd�dejj�Z
ejjde
�ejjde
�ejjjddg�y)	�N)�config)�log)�BackendExceptionc�X�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zy)�SSHPExpectBackendzxThis backend copies files using scp.  List not supported.  Filenames
    should not need any quoting or this will break.c	��tjjj||�	ddlatjdkr'tjdtj�d��d|_
d|_tjrtj|_d|_
tjrtj|_
tjj|jd	�|_|jdk(|_|j"r!|j"�d
|j$��|_n|j$|_|j(r(t+j,dd|j(d
�|_nd|_|j.�d�|_|j2r(tj4�d|j2��t_dtj4vr?txj4dt7t7tj8dz����z
c_dtj4vrtxj4dz
c_tj:|_|j?�|_ y#t
$r�wxYw)zscpBackend initializerrNz4.5.0z*
                The version of pexpect, 'z�`, is too old.  We need version 4.5.0 or above to run.
                See https://gitlab.com/duplicity/duplicity/-/issues/125 for the gory details.

                Use "python3 -m pip install pexpect" to install the latest version.
                �
�scp�sftp�pexpect�@z^/���.�/z -oPort=�ServerAliveIntervalz -oServerAliveInterval=��ServerAliveCountMaxz -oServerAliveCountMax=2)!�	duplicity�backend�Backend�__init__r�ImportError�__version__r�
FatalError�	pexexpect�retry_delay�scp_commandr�sftp_command�strip_prefix�scheme�use_scp�username�hostname�host_string�path�re�sub�
remote_dir�
remote_prefix�port�ssh_options�int�timeout�ssh_askpass�use_getpass�get_password�password)�self�
parsed_urls  �H/usr/lib/python3/dist-packages/duplicity/backends/ssh_pexpect_backend.pyrzSSHPExpectBackend.__init__)s�����!�!�*�*�4��<�	������(��N�N�*�*3�*?�*?�)@�A��
���� ������%�1�1�D��"������ &� 3� 3�D���'�'�4�4�Z�5F�5F�	�R����{�{�e�+������",�"5�"5�!6�a�
�8K�8K�7L�M�D��)�2�2�D���?�?� �f�f�U�C����!�D�D�O�!�D�O� $���0��2����?�?�$*�$6�$6�#7�x�
���?P�!Q�F�� ��(:�(:�:����$;�C��F�N�N�UV�DV�@W�<X�;Y�"Z�Z�� ��(:�(:�:����"<�<��"�-�-����)�)�+��
��c�	��	�s�I4�4I?c�"�tjd|�d��tj|dd��}tj
rd}nd}	|dk(r�|j
tjdd	d
dg�}tjd|�d
|jj��d��|dk(rtjd��n�|dk(rtjd��n�|dk(r|j|j�d}�n]|dk(rtjd��nC|dk(�r;tjd��n&|dk(r�|j
tjddddg�}tjd|�d
|jj��d��|dk(rn�|dk(rtjd�n�|dk(rd}n�|dk(r�tjd�n�|dk(r~|j
tjddg�}tjd|�d
|jj��d��|dk(rn$|dk(rtjd�n	|dk(rd}��|jd��|jdk7rt!d|�d���y)z2Run an scp command, responding to password prompts�	Running '�'NT)r.�use_poll�authorizing�copying�"(?i)timeout, server not responding�(?i)pass(word|phrase .*):�(?i)permission denied�authenticityzState = z, Before = 'rzFailed to authenticaterzTimeout waiting to authenticater�zInvalid SSH password�z>Remote host authentication failed (missing known_hosts entry?)�stalled�ETA�Timeout waiting for responsez"Stalled for too long, aborted copy��force�Error running ')r�Infor�spawnrr/�expect�EOF�Debug�before�strip�Warn�sendliner2�close�
exitstatusr)r3�commandline�child�state�matchs     r5�run_scp_commandz!SSHPExpectBackend.run_scp_commandcsf�����9�[�M��+�,��
�
�k�4�$�
�G�����!�E��E���
�%�������<�3�/�&�����	�	�H�U�G�<����8J�8J�8L�7M�Q�O�P��A�:��H�H�5�6���a�Z��H�H�>�?���a�Z��N�N�4�=�=�1�%�E��a�Z��H�H�3�4���a�Z��H�H�]�^���)�#�������<�!�&������	�	�H�U�G�<����8J�8J�8L�7M�Q�O�P��A�:���a�Z��H�H�;�<���a�Z�%�E��a�Z��H�H�]�^���)�#����g�k�k�3W�Y^�%_�`���	�	�H�U�G�<����8J�8J�8L�7M�Q�O�P��A�:���a�Z��H�H�A�B���a�Z�%�E�s�t	���$������q� �"�_�[�M��#C�D�D�!�c
���d}tjdddddddd	d
g
}t|ddD�cgc]
}t|���c}�}t	j
d
|�d��tj
|d|tjd��}d}d}		d}
|j|||z��}t	jd|jj��d��|dk(r�nd|dk(rd}
�n[|dk(rd|t|�kr6||}t	j
d|�d��|j|�|dz
}�nd}|j|�|j}
n�|dk(r0|	dz
}	|j|j�|	dkDr�td��|dk(r,|jj�j!d�s�d}
n�|dk(rd}
n�|d k(r0|jj�j!d!�sTd"|�d�}
nO|d#k(r0|jj�j!d$�sd%|�d�}
n|d&k(rd%|�d�}
n|d'k(rd(|�d�}
n���|j#d�)�|j$dk(r
Std*|�d+|
����cc}w),zORun an sftp command, responding to password prompts, passing commands from listi�r<zsftp>r=r>r?z(?i)no such file or directoryz/Couldn't delete file: No such file or directoryzCouldn't delete filezopen(.*): FailurerNr7r8T)r.�maxread�encodingr9rr)�searchwindowsizezState = sftp, Before = 'rDrzsftp command: '�quitr@zInvalid SSH password.rA�mkdirzPermission denied�zHHost key authenticity could not be verified (missing known_hosts entry?)��rmz4Remote file or directory does not exist in command='��Removingz"Could not delete file in command='��	z Could not open file in command='rErGz': )rrK�max�lenrrHrIr�
fsencodingrJrLrMrNrPr2r�
startswithrQrR)r3rS�commandsrZ�	responses�p�max_response_lenrT�cmdloc�
passprompt�msgrV�command�ress              r5�run_sftp_commandz"SSHPExpectBackend.run_sftp_command�s������K�K�0��'�#��+�=�"��
�	��	�!�"�
�>�1��A��>�?�����9�[�M��+�,��
�
�����&�&���
�����
���C��L�L��W�GW�=W�L�X�E��I�I�0����1C�1C�1E�0F�a�H�I���z���!��4�����z��C��M�)�&�v�.�G��H�H��w�i�q�9�:��N�N�7�+��a�K�F�$�G��N�N�7�+��,�,�C��!���a��
����t�}�}�-���>�*�+B�C�C��!���|�|�)�)�+�6�6�w�?�-�C���!��`����!���|�|�)�)�+�6�6�t�<�P�Q\�P]�]^�_�C���!���|�|�)�)�+�6�6�z�B�>�{�m�1�M�C���!��:�;�-�q�I����!��8��
�Q�G���Y�Z	���$������q� ��J�"�_�[�M��S�E�#J�K�K��y ?s�I0c��tj|�}|jr|j||�y|j	||�y�N)�os�fsdecoder"�put_scp�put_sftp)r3�source_path�remote_filenames   r5�_putzSSHPExpectBackend._put�s3���+�+�o�6���<�<��L�L��o�6��M�M�+��7rXc	��d|j�d|j�d|�d�d|j�d|�d|j�|�d�g}|j�dtj�d|j
��}|j
||�y)	Nzput "�" "rz.part"zrename "z.part" "�"� )�uc_namer*rrr,r%rs)r3rzr{rjrSs     r5ryzSSHPExpectBackend.put_sftp�s����K�'�'�(��D�,>�,>�+?�q��@Q�QW�X��t�)�)�*�!�O�+<�H�T�EW�EW�DX�Yh�Xi�ij�k�
���*�*�+�1�V�-?�-?�,@��$�BR�BR�AS�T�����k�8�4rXc
��|j�dtj�d|j�d|j�d|j
�|��
}|j
|�y�Nr��:)rrr,r�r%r*rW)r3rzr{rSs    r5rxzSSHPExpectBackend.put_scpsc����� ��&�"4�"4�!5�Q�{�7J�7J�6K�1���� ��$�"4�"4�!5�o�5F�
H�	�	
���[�)rXc��tj|�}|jr|j||�y|j	||�yru)rvrwr"�get_scp�get_sftp)r3r{�
local_paths   r5�_getzSSHPExpectBackend._gets3���+�+�o�6���<�<��L�L��*�5��M�M�/�:�6rXc��d|j�|�d|j�d�g}|j�dtj�d|j
��}|j
||�y)Nzget "r~rr�)r*r�rrr,r%rs)r3r{r�rjrSs     r5r�zSSHPExpectBackend.get_sftpsh���D�.�.�/��/@��J�DV�DV�CW�WX�Y�Z���*�*�+�1�V�-?�-?�,@��$�BR�BR�AS�T�����k�8�4rXc
��|j�dtj�d|j�d|j�|�d|j
��
}|j
|�yr�)rrr,r%r*r�rW)r3r{r�rSs    r5r�zSSHPExpectBackend.get_scpsd����� ���!�!�"�!���� ��$�"4�"4�!5�o�5F�a��!�!�"�
$�	�	
���[�)rXc���|jjtj�}t	|�dkDr
|ddk(rd|d<g}|D]}|d|�d�gd|�d�gzz
}�|dgz}|j
�dtj�d|j��}|j||�jd	�d
d}ttj|�D�cgc]}|s�|��	c}Scc}w)Nrrrzmkdir "r�cd "zls -1r��
r)
r)�splitrv�seprgrrr,r%rs�map�strrN)r3�dirs�mkdir_commands�drjrS�l�xs        r5�_listzSSHPExpectBackend._list!s������$�$�R�V�V�,���t�9�q�=��A�w�"�}���Q�����	?�A�����1�~�.�D���1�+��>�>�N�	?�"�W�I�-���*�*�+�1�V�-?�-?�,@��$�BR�BR�AS�T���!�!�+�x�8�>�>�t�D�Q�R�H���s�y�y�!�,�2�a���2�2��2s�C!�C!c���d|j�d�g}|jdtj|��d��|j�dt
j�d|j��}|j||�y�Nr�rzrm "r��	r)�appendrvrwrrr,r%rs)r3�filenamerjrSs    r5�_deletezSSHPExpectBackend._delete4sr���4�?�?�+�1�-�.�����$�r�{�{�8�4�5�Q�7�8��*�*�+�1�V�-?�-?�,@��$�BR�BR�AS�T�����k�8�4rXc��d|j�d�g}|D]*}|jdtj|��d���,|j�dt
j�d|j��}|j||�yr�r�)r3�
filename_listrjr�rSs     r5�_delete_listzSSHPExpectBackend._delete_list:s����4�?�?�+�1�-�.��%�	=�H��O�O�d�2�;�;�x�#8�"9��;�<�	=��*�*�+�1�V�-?�-?�,@��$�BR�BR�AS�T�����k�8�4rXN)�__name__�
__module__�__qualname__�__doc__rrWrsr|ryrxr�r�r�r�r�r��rXr5rr%sJ��7�8,�tDE�LKL�Z8�5�*�7�5�
*�3�&5�5rXrzpexpect+sftpzpexpect+scp)rvr'�duplicity.backendrrr�duplicity.errorsrrrr�register_backend�uses_netloc�extendr�rXr5�<module>r�s���8
�	����-�Z5�	�)�)�1�1�Z5�z
���"�"�>�3D�E�	���"�"�=�2C�D�	�����$�$�n�m�%D�ErX

Zerion Mini Shell 1.0