HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/duplicity/backends/__pycache__/ssh_pexpect_backend.cpython-310.pyc
o

zVa�3�@s�ddlmZddlmZe��ddlmZddlZddlZddl	m
Z
ddl	mZddl	mZddl
mZddlZ	Gd	d
�d
e	jj�Ze	j�de�e	j�de�e	jj�ddg�dS)
�)�division)�standard_library)�mapN)�config)�log)�util)�BackendExceptionc@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�SSHPExpectBackendz{This backend copies files using scp.  List not supported.  Filenames
       should not need any quoting or this will break.cCs6tjj�||�zddlaWnty�wd|_d|_tjr$tj|_d|_	tj	r.tj	|_	tj�
|jd�|_|jdk|_|j
rJ|j
d|j|_n|j|_|jr\t�dd	|jd
�|_nd|_|jd|_|jrqtjd
|jt_dtjvr�tjdttjd�7_dtjvr�tjd7_tj|_|��|_dS)zscpBackend initializerrN�
�scp�sftp�pexpect�@z^/���.�/z
 -oPort=%s�ServerAliveIntervalz -oServerAliveInterval=%d��ServerAliveCountMaxz -oServerAliveCountMax=2)�	duplicity�backend�Backend�__init__r
�ImportError�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_url�r3�H/usr/lib/python3/dist-packages/duplicity/backends/ssh_pexpect_backend.pyr-s<�

zSSHPExpectBackend.__init__cCs�t�d|�tj|dd�}tjrd}nd}	|dkrh|�tjddd	d
g�}t�d||j	�
�f�|dkr<t�d
�n�|dkrFt�d�n�|dkrS|�|j
�d}n|dkr]t�d�nv|dkrgt�d�nlnj|dkr�|�tjddd
dg�}t�d||j	�
�f�|dkr�nK|dkr�t�d�nA|dkr�d}n9|dkr�t�d�n0n.|dkr�|�tjddg�}t�d||j	�
�f�|dkr�n|dkr�t�d�n|dkr�d}q|jdd�|jdkr�td|��dS)z4 Run an scp command, responding to password prompts �Running '%s'N)r,�authorizing�copyingr�"(?i)timeout, server not responding�(?i)pass(word|phrase .*):�(?i)permission denied�authenticityzState = %s, Before = '%s'rzFailed to authenticatezTimeout 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 copyT��forcezError running '%s')r�Infor
�spawnrr-�expect�EOF�Debug�before�strip�Warn�sendliner0�close�
exitstatusr)r1�commandline�child�state�matchr3r3r4�run_scp_command^s��



��

��
�4
�z!SSHPExpectBackend.run_scp_commandc

Cs�d}tjdddddddd	d
g
}tdd�|d
d�D��}t�d|�tj|d|tjd�}d}d}	d}	|j|||d�}
t�	d|j
���|
dkrLn�|
d
krSd}	n�|
dkr~|t|�krs||}t�d|f�|�
|�|d
7}nsd}|�
|�|j
}nh|
dkr�|d
7}|�
|j�|d
kr�td��nQ|
dkr�|j
���d�s�d}	nCnA|
dkr�d}	n;|
d kr�|j
���d!�s�d"|f}	n)n'|
d#kr�|j
���d$�s�d%|f}	nn|
d&kr�d%|f}	n|
d'kr�d(|f}	nq2|jd)d*�|jdkr�|Std+||	f��),zQ Run an sftp command, responding to password prompts, passing commands from list i�r8zsftp>r9r:r;z(?i)no such file or directoryz/Couldn't delete file: No such file or directoryzCouldn't delete filezopen(.*): FailurecSsg|]}t|��qSr3)�len)�.0�pr3r3r4�
<listcomp>��z6SSHPExpectBackend.run_sftp_command.<locals>.<listcomp>rNr5)r,�maxread�encodingrr)�searchwindowsizezState = sftp, Before = '%s'r@rzsftp command: '%s'�quitr<zInvalid SSH password.r=�mkdirzPermission denied�zHHost key authenticity could not be verified (missing known_hosts entry?)��rmz7Remote file or directory does not exist in command='%s'��Removingz%Could not delete file in command='%s'��	z#Could not open file in command='%s'TrAzError running '%s': %s)r
rF�maxrrCrDr�
fsencodingrErGrHrIrSrKr0r�
startswithrLrM)
r1rN�commandsrX�	responses�max_response_lenrO�cmdloc�
passprompt�msgrQ�command�resr3r3r4�run_sftp_command�s��
�


��
�
�

�.
z"SSHPExpectBackend.run_sftp_commandcCs0t�|�}|jr|�||�dS|�||�dS�N)r�fsdecoder �put_scp�put_sftp)r1�source_path�remote_filenamer3r3r4�_put��
zSSHPExpectBackend._putcCsJd|j|j|fd|j||j|fg}d|jtj|jf}|�||�dS)Nzput "%s" "%s.%s.part"zrename "%s.%s.part" "%s%s"�%s %s %s)�uc_namer(rrr*r#ro)r1rtrurgrNr3r3r4rs�s����zSSHPExpectBackend.put_sftpcCs,d|jtj|j|j|j|f}|�|�dS)Nz%s %s %s %s:%s%s)rrr*ryr#r(rR)r1rtrurNr3r3r4rr����zSSHPExpectBackend.put_scpcCs0t�|�}|jr|�||�dS|�||�dSrp)rrqr �get_scp�get_sftp)r1ru�
local_pathr3r3r4�_get�rwzSSHPExpectBackend._getcCs8d|j||jfg}d|jtj|jf}|�||�dS)Nzget "%s%s" "%s"rx)r(ryrrr*r#ro)r1rur}rgrNr3r3r4r|s��zSSHPExpectBackend.get_sftpcCs,d|jtj|j|j||jf}|�|�dS)Nz%s %s %s:%s%s %s)rrr*r#r(ryrR)r1rur}rNr3r3r4r{
rzzSSHPExpectBackend.get_scpcCs�|j�tj�}t|�dkr|ddkrd|d<g}|D]}|d|gd|g7}q|dg}d|jtj|jf}|�	||��d�d	d�}d
d�t
djj|�D�S)Nrrrz
mkdir "%s"�cd "%s"zls -1rx�
rcSsg|]}|r|�qSr3r3)rT�xr3r3r4rV#rWz+SSHPExpectBackend._list.<locals>.<listcomp>)
r'�split�os�seprSrrr*r#ror�	__class__rI)r1�dirs�mkdir_commands�drgrN�lr3r3r4�_lists
�zSSHPExpectBackend._listcCsFd|jfg}|�dt�|��d|jtj|jf}|�||�dS�Nrzrm "%s"rx�	r'�appendrrqrrr*r#ro)r1�filenamergrNr3r3r4�_delete%szSSHPExpectBackend._deletecCsPd|jfg}|D]}|�dt�|��q	d|jtj|jf}|�||�dSr�r�)r1�
filename_listrgr�rNr3r3r4�_delete_list+s
zSSHPExpectBackend._delete_listN)�__name__�
__module__�__qualname__�__doc__rrRrorvrsrrr~r|r{r�r�r�r3r3r3r4r	*s1@F
r	zpexpect+sftpzpexpect+scp)�
__future__r�futurer�install_aliases�builtinsrr�r%rrrr�duplicity.errorsr�duplicity.backendrrr	�register_backend�uses_netloc�extendr3r3r3r4�<module>s"