%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/
Upload File :
Create Path :
Current File : //proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyc

�
��Abc@s'dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZe
e
f\ZZyddlZWnek
r�ZeZnXddlmZmZdZd	efd
��YZd�Zdefd
��YZdefd��YZdS(s2
Configuration file (aka ``ssh_config``) support.
i����N(tsha1(tpartiali(tStringIO(tCouldNotCanonicalizetConfigParseErrorit	SSHConfigc
BsWeZdZejd�Zidddddddd	gd
6dgd6ddd
ddd	dgd6ddddgd6dd
ddddddd	g	d6Zd�Zed��Z	ed��Z
ed��Zd�Zd�Z
d#ed�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zd"�ZRS($s�
    Representation of config information as stored in the format used by
    OpenSSH. Queries can be made via `lookup`. The format is described in
    OpenSSH's ``ssh_config`` man page. This class is provided primarily as a
    convenience to posix users (since the OpenSSH format is a de-facto
    standard on posix) but should work fine on Windows too.

    .. versionadded:: 1.6
    s(\w+)(?:\s*=\s*|\s+)(.+)s%Cs%hs%ls%Ls%ns%ps%rs%utcontrolpaththostnamet~s%dtidentityfiletproxycommands
match-execcCs
g|_dS(s�
        Create a new OpenSSH config object.

        Note: the newer alternate constructors `from_path`, `from_file` and
        `from_text` are simpler to use, as they parse on instantiation. For
        example, instead of::

            config = SSHConfig()
            config.parse(open("some-path.config")

        you could::

            config = SSHConfig.from_file(open("some-path.config"))
            # Or more directly:
            config = SSHConfig.from_path("some-path.config")
            # Or if you have arbitrary ssh_config text from some other source:
            config = SSHConfig.from_text("Host foo\n\tUser bar")
        N(t_config(tself((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyt__init__HscCs|jt|��S(sg
        Create a new, parsed `SSHConfig` from ``text`` string.

        .. versionadded:: 2.7
        (t	from_fileR(tclsttext((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyt	from_text]scCs&t|��}|j|�SWdQXdS(sr
        Create a new, parsed `SSHConfig` from the file found at ``path``.

        .. versionadded:: 2.7
        N(topenR(Rtpathtflo((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyt	from_pathfscCs|�}|j|�|S(sp
        Create a new, parsed `SSHConfig` from file-like object ``flo``.

        .. versionadded:: 2.7
        (tparse(RRtobj((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyRps	
cCs�idgd6id6}x�|D]�}|j�}|s|jd�rLqntj|j|�}|stdj|���n|jd�j�}|jd�}|dkr|j	j
|�iid6}|dkr�|j|�|d<q�|j|�|d	<q|d
kr3|j�dkr3d|d|<q|jd�ra|jd�ra|dd
!}n|dkr�||dkr�|d|j
|�q�|g|d|<q||dkr||d|<qqW|j	j
|�dS(s�
        Read an OpenSSH config from the given file object.

        :param file_obj: a file-like object to read the config file from
        t*thosttconfigt#sUnparsable line {}iitmatchtmatchesR
tnonet"i����R	tlocalforwardt
remoteforwardN(RR(R	R R!(tstript
startswithtreRtSETTINGS_REGEXRtformattgrouptlowerRtappendt
_get_hostst_get_matchestNonetendswith(Rtfile_objtcontexttlineRtkeytvalue((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR{s6

cCs�|jd|�}d|kr+||d<n|jdd
�dk}t|jdd��}|r�|jd�|kr�|dj�}|j|||�}||d<|j||d	t�}n|S(s�
        Return a dict (`SSHConfigDict`) of config options for a given hostname.

        The host-matching rules of OpenSSH's ``ssh_config`` man page are used:
        For each parameter, the first obtained value will be used.  The
        configuration files contain sections separated by ``Host`` and/or
        ``Match`` specifications, and that section is only applied for hosts
        which match the given patterns or keywords

        Since the first obtained value for each parameter is used, more host-
        specific declarations should be given near the beginning of the file,
        and general defaults at the end.

        The keys in the returned dict are all normalized to lowercase (look for
        ``"port"``, not ``"Port"``. The values are processed according to the
        rules for substitution variable expansion in ``ssh_config``.

        Finally, please see the docs for `SSHConfigDict` for deeper info on
        features such as optional type conversion methods, e.g.::

            conf = my_config.lookup('myhost')
            assert conf['passwordauthentication'] == 'yes'
            assert conf.as_bool('passwordauthentication') is True

        .. note::
            If there is no explicitly configured ``HostName`` value, it will be
            set to the being-looked-up hostname, which is as close as we can
            get to OpenSSH's behavior around that particular option.

        :param str hostname: the hostname to lookup

        .. versionchanged:: 2.5
            Returns `SSHConfigDict` objects instead of dict literals.
        .. versionchanged:: 2.7
            Added canonicalization support.
        .. versionchanged:: 2.7
            Added ``Match`` support.
        Rtcanonicalizehostnametyestalwaystcanonicalizemaxdotsit.tcanonicaldomainst	canonicalN(R4R5(t_lookuptgetR,tinttcounttsplittcanonicalizetTrue(RRtoptionstcanontmaxdotstdomains((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pytlookup�s(

cs0�dkrt��nx�|jD]�}|j|jdg�|�pg|j|jdg�||��spq"nx}|dj�D]k\�}��kr�|dk	r�|n|��<q��dkr���j��fd�|D��q�q�Wq"W|j�|��d�kr,�ddkr,�d=n�S(NRRRR	c3s%|]}|��kr|VqdS(N((t.0tx(R1RA(sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pys	<genexpr>	sR
(	R,t
SSHConfigDictRt_pattern_matchesR;t_does_matchtitemstextendt_expand_variables(RRRAR9R/R2((R1RAsD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR:�s" 
%
cCs�t}x||D]t}dj||�}t||�}|dk	rM|d}n*ytj|�}Wntjk
rvnX|r
|Sq
W|jdd�dkr�|St|��dS(sg
        Return canonicalized version of ``hostname``.

        :param str hostname: Target hostname.
        :param options: An `SSHConfigDict` from a previous lookup pass.
        :param domains: List of domains (e.g. ``["paramiko.org"]``).

        :returns: A canonicalized hostname if one was found, else ``None``.

        .. versionadded:: 2.7
        s{}.{}itcanonicalizefallbacklocalR4N(	tFalseR&t_addressfamily_host_lookupR,tsockett
gethostbynametgaierrorR;R(RRRARDtfoundtdomaint	candidatetfamily_specific((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR?s

cCs2t�}x"|jD]}|j|d�qW|S(s�
        Return the set of literal hostnames defined in the SSH config (both
        explicit hostnames and wildcard entries).
        R(tsetRtupdate(Rthoststentry((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyt
get_hostnames<s	cCs�t|d�r!|jd�}nt}xR|D]J}|jd�r]tj||d�r]tStj||�r.t}q.q.W|S(NR>t,t!i(thasattrR>ROR#tfnmatchR@(RtpatternsttargetRtpattern((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyRIFs

cCs|j||�S(N(RI(RRZR((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyt_allowedXscCs�g}|}tj�}x�|r�|jd�}d}	|jdd�}
|jdd�}|d|d}}
|dkr�|j||�r�tSn|dkr�tS|dkr�|
p�|}|j|
|�}	n�|d	kr�|j|
|�}	n�|dkr |p|}|j|
|�}	n{|d
krA|j|
|�}	nZ|dkr�|j	||d|
�}t
dkrzt�nt
j|d
ddt�j
}	n|	dk	r�|j|	|�r�tS|j|�qW|S(NiRtuserttypetparamR9tallRtoriginalhostt	localusertexecs
match-execthidetstdouttwarn(tgetpasstgetusertpopR,R;t_should_failROR@RIt	_tokenizetinvoketinvoke_import_errortruntokR)(Rt
match_listttarget_hostnameR9RAtmatchedt
candidatestlocal_usernameRVtpassedtconfigured_hosttconfigured_userttype_RgthostvalRetexec_cmd((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyRJ[sD		!cCs|dr|S|S(Ntnegate((Rt
would_passRV((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyRr�scCs�|j|�}|s|S|}|dkr@|jd|�}nd|krY|d}nt}tj�}d|kr�|d}	n|}	tj�jd�d}
t||
�}t	j
jd�}|
|t|�|	}
i
t
|
j��j�d6|d6|d	6|
d
6|d6|d6|d
6|	d6|d6|d6}|}xD|j�D]6\}}||krkqMn|j|t|��}qMW|S(s�
        Tokenize a string based on current config/hostname data.

        :param config: Current config data.
        :param target_hostname: Original target connection hostname.
        :param key: Config key being tokenized (used to filter token list).
        :param value: Config value being tokenized.

        :returns: The tokenized version of the input ``value`` string.
        RtportReR7iRs%Cs%ds%hs%Ls%ls%ns%ps%rs%u(t_allowed_tokensR;tSSH_PORTRoRpRQtgethostnameR>tLazyFqdntosRt
expandusertreprRtencodet	hexdigestRKtreplacetstr(RRRyR1R2tallowed_tokenstconfigured_hostnameR�Ret
remoteusertlocal_hostnamet
local_fqdnthomedirttohashtreplacementst	tokenizedtfindR�((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyRs�sD


cCs|jj|g�S(sJ
        Given config ``key``, return list of token strings to tokenize.

        .. note::
            This feels like it wants to eventually go away, but is used to
            preserve as-strict-as-possible compatibility with OpenSSH, which
            for whatever reason only applies some tokens to some config keys.
        (tTOKENS_BY_CONFIG_KEYR;(RR1((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR��s	cCs�x�|D]�}||dkr#qnt|j|||�}t||t�r�xIt||�D] \}}||�|||<q_Wq|||�||<qW|S(sA
        Return a dict of config options with expanded substitutions
        for a given original & current target hostname.

        Please refer to :doc:`/api/config` for details.

        :param dict config: the currently parsed config
        :param str hostname: the hostname whose config is being looked up
        N(R,RRst
isinstancetlistt	enumerate(RRRytkt	tokenizertiR2((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyRM�s

cCs>ytj|�SWn&tk
r9tdj|���nXdS(s>
        Return a list of host_names from host value.
        sUnparsable host {}N(tshlexR>t
ValueErrorRR&(RR((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR*�s
c
s�g}tj|�}x�|r�idd6dd6td6}|jd�}|jd�rnt|d<|d}n||d<|dkr�|j|�qn|s�td	j	|���n|jd�|d<|j|�qWg|D]}|d^q�}d|kr�d�t
t�fd
�|��t
t�fd�|��}}d}	t|�r`d}	n3d|kr�|j
d�|j
d�kr�d
}	n|	dk	r�t|	��q�n|S(s�
        Parse a specific Match config line into a list-of-dicts for its values.

        Performs some parse-time validation as well.
        RfRgR�iR^iRhR9s'Missing parameter to Match '{}' keywordcs
|�kS(N((RG(t	allowable(sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyt<lambda>tcs
|�kS(N((RG(R�(sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR�R�s>Match does not allow 'all' mixed with anything but 'canonical's-Match does not allow 'all' before 'canonical'N(RhR9(RhR9(R�R>R,RORqR#R@R)RR&R�tfiltertanytindex(
RRRttokensR�RGtkeywordsRwtbadterr((R�sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR+�s<	



"	*	N(t__name__t
__module__t__doc__R$tcompileR%R�R
tclassmethodRRRRRER,ROR:R?R\RIRdRJRrRsR�RMR*R+(((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR/s4	
%		
	=	:!	)	
			4		>				cCs�|jdd�j�}|dkr(dSyJtj}|dkrLtj}ntj|d|tjtjtj	�SWntj
k
r�nXdS(s
    Try looking up ``hostname`` in an IPv4 or IPv6 specific manner.

    This is an odd duck due to needing use in two divergent use cases. It looks
    up ``AddressFamily`` in ``options`` and if it is ``inet`` or ``inet6``,
    this function uses `socket.getaddrinfo` to perform a family-specific
    lookup, returning the result if successful.

    In any other situation -- lookup failure, or ``AddressFamily`` being
    unspecified or ``any`` -- ``None`` is returned instead and the caller is
    expected to do something situation-appropriate like calling
    `socket.gethostbyname`.

    :param str hostname: Hostname to look up.
    :param options: `SSHConfigDict` instance w/ parsed options.
    :returns: ``getaddrinfo``-style tuples, or ``None``, depending.
    t
addressfamilyR�Ntinet(R;R(RQtAF_INET6tAF_INETtgetaddrinfoR,t
SOCK_DGRAMt
IPPROTO_IPtAI_CANONNAMERS(RRAtaddress_familytfamily((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyRP&s 	R�cBs#eZdZdd�Zd�ZRS(s7
    Returns the host's fqdn on request as string.
    cCsd|_||_||_dS(N(R,tfqdnRR(RRR((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR
Ps		c	Cs�|jdkr�d}t|j|j�}|dk	r{xB|D]7}|\}}}}}|r=d|kr=|}Pq=q=Wn|dkr�tj�}n||_n|jS(NR7(R�R,RPRRRQtgetfqdn(	RR�tresultstrestaftsocktypetprotot	canonnametsa((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyt__str__Us
N(R�R�R�R,R
R�(((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR�KsRHcBs)eZdZd�Zd�Zd�ZRS(s�
    A dictionary wrapper/subclass for per-host configuration structures.

    This class introduces some usage niceties for consumers of `SSHConfig`,
    specifically around the issue of variable type conversions: normal value
    access yields strings, but there are now methods such as `as_bool` and
    `as_int` that yield casted values instead.

    For example, given the following ``ssh_config`` file snippet::

        Host foo.example.com
            PasswordAuthentication no
            Compression yes
            ServerAliveInterval 60

    the following code highlights how you can access the raw strings as well as
    usefully Python type-casted versions (recalling that keys are all
    normalized to lowercase first)::

        my_config = SSHConfig()
        my_config.parse(open('~/.ssh/config'))
        conf = my_config.lookup('foo.example.com')

        assert conf['passwordauthentication'] == 'no'
        assert conf.as_bool('passwordauthentication') is False
        assert conf['compression'] == 'yes'
        assert conf.as_bool('compression') is True
        assert conf['serveraliveinterval'] == '60'
        assert conf.as_int('serveraliveinterval') == 60

    .. versionadded:: 2.5
    cOstt|�j||�dS(N(tsuperRHR
(Rtargstkwargs((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyR
�scCs-||}t|t�r|S|j�dkS(s�
        Express given key's value as a boolean type.

        Typically, this is used for ``ssh_config``'s pseudo-boolean values
        which are either ``"yes"`` or ``"no"``. In such cases, ``"yes"`` yields
        ``True`` and any other value becomes ``False``.

        .. note::
            If (for whatever reason) the stored value is already boolean in
            nature, it's simply returned.

        .. versionadded:: 2.5
        R4(R�tboolR((RR1tval((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pytas_bool�s
cCst||�S(s�
        Express given key's value as an integer, if possible.

        This method will raise ``ValueError`` or similar if the value is not
        int-appropriate, same as the builtin `int` type.

        .. versionadded:: 2.5
        (R<(RR1((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pytas_int�s	(R�R�R�R
R�R�(((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyRHqs 		(R�R`RoR�R$R�RQthashlibRt	functoolsRt	py3compatRR,RtRutImportErrortet
ssh_exceptionRRR�tobjectRRPR�tdictRH(((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/config.pyt<module>s*
��	%&

Zerion Mini Shell 1.0