-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/transport/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyc


;Zc@@sndZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZmZyddlZWnek
rZdZnXddlmZdejfdYZiaiaeedd4Ze	jd	kped5kZdefd
YZeZ e j!Z"e j#Z$e j%Z&dZ'defdYZ(defdYZ)de)fdYZ*e&de*de)fdYZ+e,e-e.ej/fZ0edk	r/e+Z1e&de1e&de1e$e1e0ej2f7Z0[1nde)fdYZ3de3fdYZ4e&de4de3fd YZ5e&d!e5d"e3fd#YZ6e&d$e6d%e3fd&YZ7e&d'e7d(Z8d)Z9d*Z:d+Z;d,Z<ddl=Z=e>Z?d-Z@d.efd/YZAd0eAfd1YZBd2eAfd3YZCdS(6s1Foundation SSH support for SFTP and smart server.i(tabsolute_importN(tconfigterrorstosutilsttracetui(t
SFTPClienttStrangeHostnamecB@seZdZRS(s8Refusing to connect to strange SSH hostname %(hostname)s(t__name__t
__module__t_fmt(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR0st__version_info__twin32iitSSHVendorManagercB@sneZdZdZdZdZdZddZdZ	dZ
dZd	Zdd
Z
RS(sManager for manage SSH vendors.cC@si|_d|_d|_dS(N(t_ssh_vendorstNonet_cached_ssh_vendort_default_ssh_vendor(tself((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt__init__Is		cC@s
||_dS(sRegister default SSH vendor.N(R(Rtvendor((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pytregister_default_vendorNscC@s||j|<dS(s Register new SSH vendor by name.N(R(RtnameR((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pytregister_vendorRscC@s
d|_dS(s&Clear previously cached lookup result.N(RR(R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pytclear_cacheVscC@s|dkrtj}nd|kr|d}y|j|}WnGtk
r|j|}|dkr|tj|n||_nX|SdS(sReturn the vendor or None based on BZR_SSH environment variable.

        :raises UnknownSSH: if the BZR_SSH environment variable contains
                            unknown vendor name
        tBZR_SSHN(	RtostenvironRtKeyErrort_get_vendor_from_pathRt
UnknownSSHtexecutable_path(Rtenvironmenttvendor_nameR((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt_get_vendor_by_environmentZs


cC@scy=tj|dtjdtjt}|j\}}Wntk
rZd}}nX||S(s.Return SSH version string from the subprocess.tstdouttstderrt(t
subprocesstPopentPIPEtos_specific_subprocess_paramstcommunicatetOSError(RtargstpR#R$((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt_get_ssh_version_stringns	
cC@sd	}d|kr+tjdt}n{d|krPtjdt}nVd|krutjdt}n1d|kr|dkrtjdt}n|S(
sReturn the vendor or None based on output from the subprocess.

        :param version: The output of 'ssh -V' like command.
        :param args: Command line that was run.
        tOpenSSHsssh implementation is OpenSSHsSSH Secure Shellsssh implementation is SSH Corp.tlshsssh implementation is GNU lsh.tplinks$ssh implementation is Putty's plink.N(RRtmuttertOpenSSHSubprocessVendortSSHCorpSubprocessVendortLSHSubprocessVendortPLinkSubprocessVendor(RtversiontprognameR((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt_get_vendor_by_version_stringzs



cC@s%|jddg}|j|dS(sDReturn the vendor or None by checking for known SSH implementations.tsshs-V(R.R9(RR7((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt_get_vendor_by_inspectionscC@sA|j|dg}|j|tjjtjj|dS(s=Return the vendor or None using the program at the given paths-Vi(R.R9Rtpathtsplitexttbasename(RR<R7((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs	cC@s|jdkr|j|}|dkry|j}|dkrytjd|j}|dkrvtjqvqyn||_n|jS(sFind out what version of SSH is on the system.

        :raises SSHVendorNotFound: if no any SSH vendor is found
        :raises UnknownSSH: if the BZR_SSH environment variable contains
                            unknown vendor name
        s&falling back to default implementationN(	RRR"R;RR2RRtSSHVendorNotFound(RR R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt
get_vendors
	N(RR	t__doc__RRRRRR"R.R9R;RR@(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR
As								cC@sZddl}|j|j|j|j|j|jkrV|j|j|jndS(Ni(tsignaltSIGINTtSIG_IGNt	getsignaltSIGQUITtSIG_DFL(RB((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt_ignore_signalsstSocketAsChannelAdaptercB@sDeZdZdZdZdZdZdZdZRS(sCSimple wrapper for a socket that pretends to be a paramiko Channel.cC@s
||_dS(N(t_SocketAsChannelAdapter__socket(Rtsock((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRscC@sdS(Nsbzr SocketAsChannelAdapter((R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pytget_namescC@s|jj|S(N(RJtsend(Rtdata((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRMscC@scy|jj|SWnHtjk
r^}|jdtjtjtjtj	fkrXdSnXdS(NiR%(
RJtrecvtsocketterrorR,terrnotEPIPEt
ECONNRESETtECONNABORTEDtEBADF(Rtnte((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyROscC@stS(N(tTrue(R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt
recv_readyscC@s|jjdS(N(RJtclose(R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR[s(	RR	RARRLRMRORZR[(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRIs					t	SSHVendorcB@s2eZdZdZdZddddZRS(s3Abstract base class for SSH vendor implementations.cC@st|jdS(seMake an SSH connection, and return an SFTPClient.

        :param username: an ascii string
        :param password: an ascii string
        :param host: a host name as an ascii string
        :param port: a port number
        :type port: int

        :raises: ConnectionError if it cannot connect.

        :rtype: paramiko.sftp_client.SFTPClient
        N(tNotImplementedErrortconnect_sftp(Rtusernametpasswordthosttport((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR^s
cC@st|jdS(sEMake an SSH connection.

        :returns: an SSHConnection.
        N(R]tconnect_ssh(RR_R`RaRbtcommand((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRcssUnable to connect to SSH hostc	C@s(tjd|d|d|d|dS(sRaise a SocketConnectionError with properly formatted host.

        This just unifies all the locations that try to raise ConnectionError,
        so that they format things properly.
        RaRbtmsgt
orig_errorN(RtSocketConnectionError(RRaRbRfRe((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt_raise_connection_errorsN(RR	RAR^RcRRh(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR\s
		tLoopbackVendorcB@seZdZdZRS(s<SSH "vendor" that connects over a plain TCP socket, not SSH.cC@setj}y|j||fWn/tjk
rT}|j|d|d|nXtt|S(NRbRf(RPtconnectRQRhRRI(RR_R`RaRbRKRX((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR^
s(RR	RAR^(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRi
stloopbacktParamikoVendorcB@s)eZdZdZdZdZRS(sVendor that uses paramiko.cC@s:ty6tj||pdf}|jd|jWn8tjtjfk
rw}|j|d|d|nX|j	}tj
j|j}|j
}	|tkr|	t|krt||	}
tj
j|
j}n|tkr2|	t|kr2t||	}
tj
j|
j}ntjd|	||fttdd}|dk	rtj||	|n|tj|i|	<|}
tj
j|
j}t||
kr tjjd}
tjtjd}tjd	|||fd
|
|fgnt ||||||S(Nisbzr.paramikoRbRfsAdding %s host key for %s: %stadds~/.ssh/known_hostst
ssh_host_keyss(Host keys for %s do not match!  %s != %ssTry editing %s or %s(!tload_host_keystparamikot	Transporttset_log_channeltstart_clienttSSHExceptionRPRQRhtget_remote_server_keytutilthexifytget_fingerprintRLtSYSTEM_HOSTKEYStBZR_HOSTKEYSRtwarningtgetattrRRmt
setdefaulttsave_host_keysRR<t
expanduserRtpathjoinRt
config_dirRtTransportErrort_paramiko_auth(RR_R`RaRbttRXt
server_keytserver_key_hextkeytypetour_server_keytour_server_key_hexRmt	filename1t	filename2((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt_connectsJ
				
cC@sb|j||||}y|jSWn5tjk
r]}|j|d|d|ddnXdS(NRbRfResUnable to start sftp client(Rtopen_sftp_clientRpRtRh(RR_R`RaRbRRX((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR^Isc
C@s|j||||}y6|j}dj|}|j|t|SWn5tjk
r}	|j|d|d|	ddnXdS(Nt RbRfResUnable to invoke remote bzr(Rtopen_sessiontjointexec_commandt_ParamikoSSHConnectionRpRtRh(
RR_R`RaRbRdRtchanneltcmdlineRX((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRcQs
(RR	RARR^Rc(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRls	.	RptnonetSubprocessVendorcB@sMeZdZdZedZdZdZdZ	dddZ
RS(s?Abstract base class for vendors that use pipes to a subprocess.cC@s%|jdr!td|ndS(Nt-thostname(t
startswithR(targ((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt_check_hostnamensc	C@sy#tj\}}tj|Wn3ttjfk
rXtj}}d\}}nX|}}tj	|d|d|d|j
t}|dk	r|jnt
|d|S(NtstdinR#R$RK(NN(RPt
socketpairRtset_fd_cloexectAttributeErrorRQR&R(RR't_stderr_targetR)R[tSSHSubprocessConnection(Rtargvtmy_socktsubproc_sockRR#tproc((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRss


cC@sqy>|j|||dd}|j|}tt|SWn,tk
rl}|j|d|d|nXdS(Nt	subsystemtsftpRbRf(t_get_vendor_specific_argvRRRIt_ssh_connection_errorsRh(RR_R`RaRbRRKRX((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR^s	cC@s_y,|j|||d|}|j|SWn,tk
rZ}|j|d|d|nXdS(NRdRbRf(RRRRh(RR_R`RaRbRdRRX((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRcs	cC@st|jdS(sReturns the argument list to run the subprocess with.

        Exactly one of 'subsystem' and 'command' must be specified.
        N(R]R(RR_RaRbRRd((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRsN(RR	RARRtstaticmethodRRR^RcR(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRfs				R3cB@s#eZdZdZdddZRS(s7SSH vendor that uses the 'ssh' executable from OpenSSH.R:cC@s|jddddg}|dk	r@|jdt|gn|dk	rb|jd|gn|dk	r|jdd||gn|jd|g||S(	Ns-oForwardX11=nos-oForwardAgent=nos-oClearAllForwardings=yess&-oNoHostAuthenticationForLocalhost=yess-ps-ls-ss--(RRtextendtstr(RR_RaRbRRdR,((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs	N(RR	RARRR(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR3stopensshR4cB@s#eZdZdZdddZRS(s?SSH vendor that uses the 'ssh' executable from SSH Corporation.R:cC@s|j||jdg}|dk	rD|jdt|gn|dk	rf|jd|gn|dk	r|jd||gn|j|g||S(Ns-xs-ps-ls-s(RRRRR(RR_RaRbRRdR,((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs
N(RR	RARRR(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR4stsshcorpR5cB@s#eZdZdZdddZRS(s2SSH vendor that uses the 'lsh' executable from GNUR0cC@s|j||jg}|dk	rA|jdt|gn|dk	rc|jd|gn|dk	r|jd||gn|j|g||S(Ns-ps-ls--subsystem(RRRRR(RR_RaRbRRdR,((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs
N(RR	RARRR(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR5sR0R6cB@s#eZdZdZdddZRS(s7SSH vendor that uses the 'plink' executable from Putty.R1cC@s|j||jdddddg}|dk	rP|jdt|gn|dk	rr|jd|gn|dk	r|jd||gn|j|g||S(	Ns-xs-as-sshs-2s-batchs-Ps-ls-s(RRRRR(RR_RaRbRRdR,((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs
N(RR	RARRR(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR6sR1cC@s}tj}|dkr?|jd|d|dtj}ntrtj}xk|j	D]Z}t
jdtjj
|jy|j||dSWq^tjk
r}q^Xq^Wnt|tj|drdSt|tj|drdSg}	yH|jj}
|jjtjz|j|Wd|jj|
XWn4tjk
rf}|j}	ntjk
r{}nXd|	krd|	krtjd	|||	fn|ry|j||dSWqtjk
r}qXn|jd||d|}|dk	r`y|j||Wqytjk
r\}tjd
||f|qyXntjd||fdS(NR:RbtdefaultsTrying SSH agent key %stid_rsatid_dsaR`skeyboard-interactivesFUnable to authenticate to SSH host as
  %s@%s
supported auth types: %ss.Unable to authenticate to SSH host as
  %s@%s
s,Unable to authenticate to SSH host as  %s@%s( RtAuthenticationConfigRtget_usertgetpasstgetusert_use_ssh_agentRptAgenttget_keysRR2RvRwRxtauth_publickeyRtt_try_pkey_authtRSAKeytDSSKeytloggertleveltsetLeveltloggingtWARNINGt	auth_nonetBadAuthenticationTypet
allowed_typesRtConnectionErrort
auth_passwordtget_password(R_R`RaRbtparamiko_transporttauthtagenttkeyRXtsupported_auth_typest	old_level((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRsb				cC@s#tjjd|}y'|j|}|j||tSWntjk
rtj	j
ddd|jtj
}y*|j||}|j||tSWqtjk
rtjdtjj|fqXnDtjk
rtjdtjj|fntk
rnXtS(Ns~/.ssh/tpromptuSSH %(filename)s passwordtfilenames%SSH authentication via %s key failed.(RR<Rtfrom_private_key_fileRRYRptPasswordRequiredExceptionRt
ui_factoryRtdecodeRt_fs_encRtRR2R>tIOErrortFalse(Rt
pkey_classR_RRR`((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRLs,		
cC@sy"tjjtjjdaWn*tk
rN}tj	dt
|nXtjt
jd}ytjj|aWn1tk
r}tj	dt
|tnXdS(sx
    Load system host keys (probably doesn't work on windows) and any
    "discovered" keys from previous sessions.
    s~/.ssh/known_hostss!failed to load system host keys: Rnsfailed to load bzr host keys: N(RpRvRoRR<RRyRRR2RRRRRRzR~(RXtbzr_hostkey_path((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRoes	cC@stjtjd}tjyt|d}|jdxWtjD]I\}}x:|jD],\}}|jd|||j	fqgWqNW|j
Wn*tk
r}tj
dt|nXdS(sB
    Save "discovered" host keys in $(config)/ssh_host_keys/.
    Rntws!# SSH host keys collected by bzr
s	%s %s %s
sfailed to save bzr host keys: N(RRRRtensure_config_dir_existstopentwriteRzt	iteritemst
get_base64R[RRR2R(RtfRtkeysRRRX((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR~xs

(cC@s)tjdkriSitd6td6SdS(s'Get O/S specific subprocess parameters.Rt
preexec_fnt	close_fdsN(tsystplatformRHRY(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR)s
cC@sg}x<|j|j|fD]%}|dk	r|j|jqqW|j|jx0|D](}y|Wq\tk
rq\q\Xq\WdS(sCarefully close stdin/stdout and reap the SSH process.

    If the pipes are already closed and/or the process has already been
    wait()ed on, that's ok, and no error is raised.  The goal is to do our best
    to clean up (whether or not a clean up was already tried).
    N(RR#RtappendR[twaitR+(RRKtfuncst	closeabletfunc((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt_close_ssh_procs

t
SSHConnectioncB@s eZdZdZdZRS(s(Abstract base class for SSH connections.cC@st|jdS(sReturns a (kind, io_object) pair.

        If kind == 'socket', then io_object is a socket.

        If kind == 'pipes', then io_object is a pair of file-like objects
        (read_from, write_to).
        N(R]tget_sock_or_pipes(R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRscC@st|jdS(N(R]R[(R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR[s(RR	RARR[(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs	
RcB@s>eZdZddZdZdZdZdZRS(sA connection to an ssh subprocess via pipes or a socket.

    This class is also socket-like enough to be used with
    SocketAsChannelAdapter (it has 'send' and 'recv' methods).
    c@sA|_|_fd}tjtj||dS(sConstructor.

        :param proc: a subprocess.Popen
        :param sock: if proc.stdin/out is a socket from a socketpair, then sock
            should bzrlib's half of that socketpair.  If not passed, proc's
            stdin/out is assumed to be ordinary pipes.
        c@stj|tdS(N(t_subproc_weakrefstremoveR(tref(RRK(s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt	terminates
N(Rt_sockRRmtweakrefR(RRRKR((RRKs8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs		cC@s?|jdk	r|jj|Stj|jjj|SdS(N(RRRMRRRRtfileno(RRN((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRMscC@s?|jdk	r|jj|Stj|jjj|SdS(N(RRRORtreadRR#R(Rtcount((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyROscC@st|j|jdS(N(RRR(R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR[scC@s<|jdk	rd|jfSd|jj|jjffSdS(NRPtpipes(RRRR#R(R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs
N(	RR	RARRRMROR[R(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs			RcB@s)eZdZdZdZdZRS(sAn SSH connection via paramiko.cC@s
||_dS(N(R(RR((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRscC@s
d|jfS(NRP(R(R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRscC@s
|jjS(N(RR[(R((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyR[s(RR	RARRR[(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyRs		(iii(iii(DRAt
__future__RRRRRRRPR&RtbzrlibRRRRRRptImportErrorRXRtparamiko.sftp_clientRtBzrErrorRRyRzR|t_paramiko_versionRRtobjectR
t_ssh_vendor_managerR@t_get_ssh_vendorRtregister_default_ssh_vendorRtregister_ssh_vendorRHRIR\RiRltEOFErrorR+RRQRRRtRR3R4R5R6RRRoR~R)RtsetRRRRR(((s8/usr/lib/python2.7/dist-packages/bzrlib/transport/ssh.pyt<module>st(
r					"$D	


=	O						.

Copyright © 2017 || Recoded By Mr.Bumblebee