Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/paramiko/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/paramiko/__pycache__/agent.cpython-38.pyc
U

P��g>�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
mZddlmZmZddlmZddlmZmZdd	lmZmZed
�ZdZed�Zd
ZdZdZeed�Z e!e �"��D]\Z#Z$e$e e#�d�<q�Gdd�d�Z%Gdd�dej&�Z'Gdd�de'�Z(Gdd�de'�Z)dd�Z*Gdd�d�Z+Gdd�de%�Z,Gd d!�d!�Z-Gd"d#�d#e%�Z.Gd$d%�d%e�Z/dS)&z
SSH Agent interface
�N)�DEBUG)�select)�io_sleep�byte_chr)�SSHException�AuthenticationException)�Message)�PKey�UnknownKeyType)�asbytes�
get_logger���
���)zrsa-sha2-256zrsa-sha2-512z-cert-v01@openssh.comc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�AgentSSHcCsd|_d|_dS�N�)�_conn�_keys��selfrr�;/opt/cppython/lib/python3.8/site-packages/paramiko/agent.py�__init__>szAgentSSH.__init__cCs|jS)a�
        Return the list of keys available through the SSH agent, if any.  If
        no SSH agent was running (or it couldn't be contacted), an empty list
        will be returned.

        This method performs no IO, just returns the list of keys retrieved
        when the connection was made.

        :return:
            a tuple of `.AgentKey` objects representing keys available on the
            SSH agent
        )rrrrr�get_keysBs
zAgentSSH.get_keyscCsd||_|�t�\}}|tkr$td��g}t|���D] }|�t||�	�|�
�d��q4t|�|_dS)Nz!could not get keys from ssh-agent)�agent�blob�comment)
r�
_send_message�cSSH2_AGENTC_REQUEST_IDENTITIES�SSH2_AGENT_IDENTITIES_ANSWERr�rangeZget_int�append�AgentKey�
get_binary�get_text�tupler)r�conn�ptype�result�keys�irrr�_connectQs��zAgentSSH._connectcCs$|jdk	r|j��d|_d|_dSr)r�closerrrrr�_closeas

zAgentSSH._closecCsXt|�}|j�t�dt|��|�|�d�}t|�t�d|�d��}t	|�
��|fS)Nz>Irr)rr�send�struct�pack�len�	_read_allr�unpack�ordZget_byte)r�msg�datarrrr gs

zAgentSSH._send_messagecCsb|j�|�}t|�|kr^t|�dkr,td��|j�|t|��}t|�dkrTtd��||7}q|S)Nr�lost ssh-agent)r�recvr4r)r�wantedr+�extrarrrr5ns
zAgentSSH._read_allN)	�__name__�
__module__�__qualname__rrr.r0r r5rrrrr=src@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�AgentProxyThreadz@
    Class in charge of communication between two channels.
    cCs"tjj||jd�||_d|_dS)N)�targetF)�	threading�Threadr�run�_agent�_exit�rrrrrrszAgentProxyThread.__init__cCspz\|��\}}||_||_|j��t|jt�sR|jjdksJt|jjd�sRt	d��|�
�Wn�YnXdS)N�filenozUnable to connect to SSH agent)�get_connection�_AgentProxyThread__inrZ_AgentProxyThread__addrrF�connect�
isinstance�intr�hasattrr�_communicate)r�r�addrrrrrE�s

��zAgentProxyThread.runcCs�ddl}|�|j|j�}|�|j|j|tjB�|js�t|jj	|jgggd�}|dD]�}|jj	|kr�|jj	�
d�}t|�dkr�|j�|�q�|�
�q�qV|j|krV|j�
d�}t|�dkr�|jj	�|�qV|�
�q�qVt�t�q0dS)Nrg�?i)�fcntlrKZF_GETFLZF_SETFL�os�
O_NONBLOCKrGrrFrr;r4r1r0�time�sleepr)rrSZoldflags�events�fdr9rrrrP�s&
zAgentProxyThread._communicatecCs d|_|j��|jj��dS)NT)rGrKr/rFrrrrrr0�s
zAgentProxyThread._closeN)r>r?r@�__doc__rrErPr0rrrrrAzs
rAc@s eZdZdZdd�Zdd�ZdS)�AgentLocalProxyz�
    Class to be used when wanting to ask a local SSH Agent being
    asked from a remote fake agent (so use a unix socket for ex.)
    cCst�||�dS�N)rArrHrrrr�szAgentLocalProxy.__init__cCsTt�tjtj�}z0|�|j���|�d�|��\}}||fWS�YnXdS)zX
        Return a pair of socket object and string address.

        May block!
        �N)�socket�AF_UNIX�SOCK_STREAM�bindrF�
_get_filename�listen�accept)rr)rQrRrrrrJ�s

zAgentLocalProxy.get_connectionN�r>r?r@rZrrJrrrrr[�sr[c@s eZdZdZdd�Zdd�ZdS)�AgentRemoteProxyzA
    Class to be used when wanting to ask a remote SSH Agent
    cCst�||�||_dSr\)rAr�_AgentRemoteProxy__chan)rrZchanrrrr�szAgentRemoteProxy.__init__cCs
|jdfSr\)rgrrrrrJ�szAgentRemoteProxy.get_connectionNrerrrrrf�srfcCs�dtjkrLtjdkrLt�tjtj�}z|�tjd�|WSYdSXnHtjdkr�ddlm	}m
}d}|��r||��}n|��r�|�
�}|SdSdS)zj
    Returns some SSH agent object, or None if none were found/supported.

    .. versionadded:: 2.10
    �
SSH_AUTH_SOCK�win32Nr])�win_pageant�win_openssh)rT�environ�sys�platformr^r_r`rL�rjrkZcan_talk_to_agentZPageantConnectionZOpenSSHAgentConnection)r)rjrkrrr�get_agent_connection�s 


rpc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�AgentClientProxya�
    Class proxying request as a client:

    #. client ask for a request_forward_agent()
    #. server creates a proxy and a fake SSH Agent
    #. server ask for establishing a connection when needed,
       calling the forward_agent_handler at client side.
    #. the forward_agent_handler launch a thread for connecting
       the remote fake agent and the local agent
    #. Communication occurs ...
    cCs&d|_||_t||�|_|j��dSr\)rZ_AgentClientProxy__chanRrf�thread�start�rZ
chanRemoterrrrszAgentClientProxy.__init__cCs|��dSr\�r/rrrr�__del__
szAgentClientProxy.__del__cCst�}|sdS||_dS)zJ
        Method automatically called by ``AgentProxyThread.run``.
        N)rpr�rr)rrrrL
szAgentClientProxy.connectcCs6t|d�rd|j_|j�d�|jdk	r2|j��dS)zh
        Close the current connection and terminate the agent
        Should be called manually
        rrT��N)rOrrrG�joinrr/rrrrr/s


zAgentClientProxy.closeN)r>r?r@rZrrvrLr/rrrrrq�s
	rqc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�AgentServerProxya�
    Allows an SSH server to access a forwarded agent.

    This also creates a unix domain socket on the system to allow external
    programs to also access the agent. For this reason, you probably only want
    to create one of these.

    :meth:`connect` must be called before it is usable. This will also load the
    list of keys the agent contains. You must also call :meth:`close` in
    order to clean up the unix socket and the thread that maintains it.
    (:class:`contextlib.closing` might be helpful to you.)

    :param .Transport t: Transport used for SSH Agent communication forwarding

    :raises: `.SSHException` -- mostly if we lost the agent
    cCsPt�|�||_t�d�|_t�|jtj	�|jd|_
t|�|_|j�
�dS)NZsshproxyz
/sshproxy.ssh)rr�_AgentServerProxy__t�tempfile�mkdtemp�_dirrT�chmod�stat�S_IRWXU�_filer[rrrs)r�trrrr4s

zAgentServerProxy.__init__cCs|��dSr\rurrrrrv=szAgentServerProxy.__del__cCs2|j��}|dkrtd��|�d�|�|�dS)Nr:z
auth-agent)r{Zopen_forward_agent_channelr�set_namer.)rZ	conn_sockrrrrL@s


zAgentServerProxy.connectcCs8t�|j�t�|j�d|j_|j�d�|��dS)zk
        Terminate the agent, clean the files, close connections
        Should be called manually
        TrxN)	rT�remover��rmdirr~rrrGryr0rrrrr/Gs
zAgentServerProxy.closecCsd|��iS)z�
        Helper for the environment under unix

        :return:
            a dict containing the ``SSH_AUTH_SOCK`` environment variables
        rh)rbrrrr�get_envRszAgentServerProxy.get_envcCs|jSr\)r�rrrrrb[szAgentServerProxy._get_filenameN)
r>r?r@rZrrvrLr/r�rbrrrrrz"s		rzc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�AgentRequestHandlera�
    Primary/default implementation of SSH agent forwarding functionality.

    Simply instantiate this class, handing it a live command-executing session
    object, and it will handle forwarding any local SSH agent processes it
    finds.

    For example::

        # Connect
        client = SSHClient()
        client.connect(host, port, username)
        # Obtain session
        session = client.get_transport().open_session()
        # Forward local agent
        AgentRequestHandler(session)
        # Commands executed after this point will see the forwarded agent on
        # the remote end.
        session.exec_command("git clone https://my.git.repository/")
    cCs"d|_||_|�|j�g|_dSr\)rZ_AgentRequestHandler__chanCZrequest_forward_agent�_forward_agent_handler�"_AgentRequestHandler__clientProxys)rZ
chanClientrrrruszAgentRequestHandler.__init__cCs|j�t|��dSr\)r�r$rqrtrrrr�{sz*AgentRequestHandler._forward_agent_handlercCs|��dSr\rurrrrrv~szAgentRequestHandler.__del__cCs|jD]}|��qdSr\)r�r/)r�prrrr/�s
zAgentRequestHandler.closeN)r>r?r@rZrr�rvr/rrrrr�_s
r�c@s eZdZdZdd�Zdd�ZdS)�Agenta�
    Client interface for using private keys from an SSH agent running on the
    local machine.  If an SSH agent is running, this class can be used to
    connect to it and retrieve `.PKey` objects which can be used when
    attempting to authenticate to remote SSH servers.

    Upon initialization, a session with the local machine's SSH agent is
    opened, if one is running. If no agent is running, initialization will
    succeed, but `get_keys` will return an empty tuple.

    :raises: `.SSHException` --
        if an SSH agent is found, but speaks an incompatible protocol

    .. versionchanged:: 2.10
        Added support for native openssh agent on windows (extending previous
        putty pageant support)
    cCs&t�|�t�}|sdS|�|�dSr\)rrrpr.rwrrrr�s

zAgent.__init__cCs|��dS)z1
        Close the SSH agent connection.
        N)r0rrrrr/�szAgent.closeN)r>r?r@rZrr/rrrrr��sr�cs`eZdZdZddd�Zdd�Zdd�Zd	d
�Z�fdd�Zd
d�Z	e
dd��Zddd�Z�Z
S)r%a�
    Private key held in a local SSH agent.  This type of key can be used for
    authenticating to a remote server (signing).  Most other key operations
    work as expected.

    .. versionchanged:: 3.2
        Added the ``comment`` kwarg and attribute.

    .. versionchanged:: 3.2
        Added the ``.inner_key`` attribute holding a reference to the 'real'
        key instance this key is a proxy for, if one was obtainable, else None.
    roc	Cs|||_||_||_t|�}|��|_tt�|_d|_	zt
j|j|d�|_	Wn,tk
rvd}|�
t|�|j��YnXdS)N)Zkey_type�	key_bytesz5Unable to derive inner_key for agent key of type {!r})rrrrr'�namer�__file__�_logger�	inner_keyr	Zfrom_type_stringr
�logr�format)rrrrr8�errrrrr�s

�zAgentKey.__init__cOs|jj||�Sr\)r�r�)r�args�kwargsrrrr��szAgentKey.logcCs|jr|j��S|jSr\)r�rrrrrrr�szAgentKey.asbytescCs|jSr\)r�rrrr�get_name�szAgentKey.get_namecs|jdk	r|j��St���Sr\)r��get_bits�superr��	__class__rrr��s

zAgentKey.get_bitscCs|jdkrt|��t|j|�S)zO
        Proxy any un-implemented methods/properties to the inner_key.
        N)r��AttributeError�getattr)rr�rrr�__getattr__�s
zAgentKey.__getattr__cCs |��|jg}|jr|jjS|Sr\)r�rr��_fields)r�fallbackrrrr��szAgentKey._fieldsNcCsbt�}|�t�|�|���|�|�|�t�|d��|j�	|�\}}|t
krZtd��|��S)Nrzkey cannot be used for signing)
rZadd_byte�cSSH2_AGENTC_SIGN_REQUESTZ
add_stringrZadd_int�ALGORITHM_FLAG_MAP�getrr �SSH2_AGENT_SIGN_RESPONSErr&)rr9�	algorithmr8r*r+rrr�
sign_ssh_data�s

zAgentKey.sign_ssh_data)ro)N)r>r?r@rZrr�rr�r�r��propertyr�r��
__classcell__rrr�rr%�s

r%)0rZrTr^r2rmrCrVr|r��loggingrrZparamiko.commonrrZparamiko.ssh_exceptionrrZparamiko.messagerZ
paramiko.pkeyr	r
Z
paramiko.utilrrr!r"r�r�ZSSH_AGENT_RSA_SHA2_256ZSSH_AGENT_RSA_SHA2_512r��list�items�key�valuerrDrAr[rfrprqrzr�r�r%rrrr�<module>sH�=;
+='"

F1le Man4ger