+
    üÐj½d  ã                  ó  € ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHt ^ R
IHtHt ^ RIHtHtHt ^ RIHt ^ RIHt ^ RI H!t! ^ RI"H#t#H$t$H%t% ^ RI&H't' ^ RI(H)t) ^ RI*H+t+ ^ RI,H-t-H.t. ^ RI/H0t0H1t1  ^ RIH2t2H3t3 ]+! R4      t5]5'       d   ^ RI6H7t7 ^ RI8H9t9H:t:H;t; M^ RI<H9t9  ! R R4      t7 ^ RI=H:t> ]>t? ! R R4      tC ! R R ]14      tD ! R! R"]PŠ                  4      tF ! R# R$]PŽ                  4      tH ! R% R&]P’                  4      tJ ! R' R(]P’                  4      tK ! R) R*]PŠ                  4      tLRAR+ R, lltM ! R- R.4      tN ! R/ R0]N4      tO]! ]94       ! R1 R2]74      4       tP ! R3 R44      tQ ! R5 R6]N4      tR ! R7 R84      tS ! R9 R:]N]S]14      tT ! R; R<]O]S]14      tU ! R= R>]R]S]14      tV ! R? R@]O]14      tWR#   ]4 d     ELIi ; i  ]4 d   t@Rt?]A! ]@4      tBA@ Rt@A@EL+Rt@A@ii ; i)Bé    )ÚannotationsN)Úcount)ÚAny)Úimplementer)Ú
ConchError)ÚprivateRSA_opensshÚpublicRSA_openssh©ÚConchTestRealm)Úportal)ÚprotocolÚreactor)ÚDeferredÚgatherResultsÚmaybeDeferred)ÚProcessExitedAlready)ÚIReactorProcess)ÚLoopingCall)ÚfilepathÚlogÚruntime)ÚFilePath)Úwhich)ÚrequireModule)ÚHAS_IPV6ÚskipWithoutIPv6)ÚSkipTestÚTestCase)ÚConchTestServerFactoryÚconchTestPublicKeyCheckerÚcryptography)Ú	ConchUser)ÚISessionÚ
SSHSessionÚwrapProtocol)r#   c                  ó   € ] tR t^/tRtR# )r"   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r'   ó    Ú?/usr/lib/python3/dist-packages/twisted/conch/test/test_conch.pyr"   r"   /   s   † Ûr-   r"   )r$   c                  ó$   € ] tR t^=tRtRtR tRtR# )Ú	FakeStdiozä
A fake for testing L{twisted.conch.scripts.conch.SSHSession.eofReceived} and
L{twisted.conch.scripts.cftp.SSHSession.eofReceived}.

@ivar writeConnLost: A flag which records whether L{loserWriteConnection}
    has been called.
Fc                ó   € RV n         R# )z)
Record the call to loseWriteConnection.
TN©ÚwriteConnLost©Úselfs   &r.   ÚloseWriteConnectionÚFakeStdio.loseWriteConnectionH   s   € ð "ˆÖr-   r2   N)r(   r)   r*   r+   Ú__doc__r3   r6   r,   r'   r-   r.   r0   r0   =   s   † ñð €Mö"r-   r0   c                  ó,   € ] tR t^OtRt]f   ]tR tRt	R# )ÚStdioInteractingSessionTestsz6
Tests for L{twisted.conch.scripts.conch.SSHSession}.
Nc                ó�   € \        4       p\        4       pWn        VP                  4        V P	                  VP
                  4       R# )ze
L{twisted.conch.scripts.conch.SSHSession.eofReceived} loses the
write half of its stdio connection.
N)r0   ÚStdioInteractingSessionÚstdioÚeofReceivedÚ
assertTruer3   )r5   r=   Úchannels   &  r.   Útest_eofReceivedÚ-StdioInteractingSessionTests.test_eofReceivedW   s6   € ô
 “ˆÜ)Ó+ˆØŒØ×ÑÔØ�‰˜×+Ñ+Ö,r-   r'   )
r(   r)   r*   r+   r8   r<   Ú_reasonÚskiprA   r,   r'   r-   r.   r:   r:   O   s   † ñð Ò&Øˆö	-r-   r:   c                  ó(   € ] tR t^ctR tR tR tRtR# )ÚEchoc                	ó2   € \         P                  ! R 4       R# )zECHO CONNECTION MADEN©r   Úmsgr4   s   &r.   ÚconnectionMadeÚEcho.connectionMaded   ó   € Ü�ŠÐ&Ö'r-   c                	ó2   € \         P                  ! R 4       R# )zECHO CONNECTION DONENrH   ©r5   Úreasons   &&r.   ÚconnectionLostÚEcho.connectionLostg   rL   r-   c                	ó‚   € V P                   P                  V4       R V9   d   V P                   P                  4        R# R# )ó   
N)Ú	transportÚwriteÚloseConnection©r5   Údatas   &&r.   ÚdataReceivedÚEcho.dataReceivedj   s0   € Ø�‰×Ñ˜TÔ"Ø�DŒ=Ø�N‰N×)Ñ)Ö+ñ r-   r'   N)r(   r)   r*   r+   rJ   rP   rY   r,   r'   r-   r.   rF   rF   c   s   † ò(ò(ö,r-   rF   c                  ó   € ] tR t^pt]tRtR# )ÚEchoFactoryr'   N)r(   r)   r*   r+   rF   r   r,   r'   r-   r.   r\   r\   p   s   † Ø„Hr-   r\   c                  óX   € ] tR t^tt$ RtRtR]R&   RtRt^ t	R]R&   R t
R	 tR
 tR tRtR# )ÚConchTestOpenSSHProcessap  
Test protocol for launching an OpenSSH client process.

@ivar deferred: Set by whatever uses this object. Accessed using
L{_getDeferred}, which destroys the value so the Deferred is not
fired twice. Fires when the process is terminated.

@ivar expectedExitCode: If the process exit code is not C{expectedExitCode}
the set C{deferred} will by triggerd with a failure.
NzDeferred[None] | NoneÚdeferredr-   ÚintÚexpectedExitCodec                	ó,   € V P                   R uqn         V# ©N©r_   ©r5   Úds   & r.   Ú_getDeferredÚ$ConchTestOpenSSHProcess._getDeferred…   ó   € ØŸ=™=¨$ÐˆŒ=Øˆr-   c                	ó8   € V ;P                   V,          un         R # rc   )ÚbufrW   s   &&r.   ÚoutReceivedÚ#ConchTestOpenSSHProcess.outReceived‰   s   € Ø�Š�DÕ�r-   c                	ó8   € V ;P                   V,          un         R # rc   )ÚproblemsrW   s   &&r.   ÚerrReceivedÚ#ConchTestOpenSSHProcess.errReceivedŒ   s   € Ø�Š˜Õ�r-   c                óª  € VP                   P                  V P                  8w  ds   V P                  4       P	                  \        RP                  V P                  VP                   P                  V P                  P                  R4      4      4      4       R# V P                  P                  RR4      pV P                  4       P                  V4       R# )zf
Called when the process has ended.

@param reason: a Failure giving the reason for the process' end.
zexit code was not {}: {} ({})Úcharmaps   
rS   N)ÚvalueÚexitCodera   rg   Úerrbackr   Úformatro   Údecoderk   ÚreplaceÚcallback)r5   rO   rk   s   && r.   ÚprocessEndedÚ$ConchTestOpenSSHProcess.processEnded�   s    € ð �<‰<× Ñ  D×$9Ñ$9Ô9Ø×ÑÓ×'Ñ'ÜØ3×:Ñ:Ø×-Ñ-ØŸ™×-Ñ-ØŸ™×,Ñ,¨YÓ7óóöð —(‘(×"Ñ" 7¨EÓ2ˆCØ×ÑÓ×(Ñ(¨Ö-r-   rd   )r(   r)   r*   r+   r8   r_   Ú__annotations__rk   ro   ra   rg   rl   rp   r{   r,   r'   r-   r.   r^   r^   t   s=   ‡ ñ	ð '+€HÐ#Ó*Ø
€CØ€HØÐ�cÓòòòö.r-   r^   c                  óN   € ] tR t^¤tRtRtR tR tR tR t	R t
R tR	 tR
 tRtR# )ÚConchTestForwardingProcessaÆ  
Manages a third-party process which launches a server.

Uses L{ConchTestForwardingPort} to connect to the third-party server.
Once L{ConchTestForwardingPort} has disconnected, kill the process and fire
a Deferred with the data received by the L{ConchTestForwardingPort}.

@ivar deferred: Set by whatever uses this object. Accessed using
L{_getDeferred}, which destroys the value so the Deferred is not
fired twice. Fires when the process is terminated.
Nc                ó,   € Wn         RV n        W n        R# )aF  
        @type port: L{int}
        @param port: The port on which the third-party server is listening.
        (it is assumed that the server is running on localhost).

        @type data: L{str}
        @param data: This is sent to the third-party server. Must end with '
'
        in order to trigger a disconnect.
        N)ÚportÚbufferrX   )r5   r�   rX   s   &&&r.   Ú__init__Ú#ConchTestForwardingProcess.__init__³   s   € ð Œ	ØˆŒØŽ	r-   c                	ó,   € V P                   R uqn         V# rc   rd   re   s   & r.   rg   Ú'ConchTestForwardingProcess._getDeferredÁ   ri   r-   c                	ó&   € V P                  4        R # rc   )Ú_connectr4   s   &r.   rJ   Ú)ConchTestForwardingProcess.connectionMadeÅ   s   € Ø�‰Žr-   c                óÈ   € \         P                  ! \        \        W P                  4      pVP                  RV P                  4      pVP                  V P                  4       V# )zæ
Connect to the server, which is often a third-party process.
Tries to reconnect if it fails because we have no way of determining
exactly when the port becomes available for listening -- we can only
know when the process starts.
ú	127.0.0.1)	r   ÚClientCreatorr   ÚConchTestForwardingPortrX   Ú
connectTCPr�   Ú
addErrbackÚ
_ebConnect)r5   Úccrf   s   &  r.   rˆ   Ú#ConchTestForwardingProcess._connectÈ   sF   € ô ×#Ò#¤GÔ-DÀdÏIÉIÓVˆØ�M‰M˜+ t§y¡yÓ1ˆØ	�‰�T—_‘_Ô%Øˆr-   c                	óH   € \         P                  ! R V P                  4       R# )gš™™™™™¹?N)r   Ú	callLaterrˆ   )r5   Úfs   &&r.   r�   Ú%ConchTestForwardingProcess._ebConnectÔ   s   € Ü×Ò˜#˜tŸ}™}Ö-r-   c                ó¾   € Wn         V P                  P                  R4       V P                  P                  4        \        P
                  ! ^ V P                  4       R# )z¶
The network connection has died; save the buffer of output
from the network and attempt to quit the process gracefully,
and then (after the reactor has spun) send it a KILL signal.
ó   N)r‚   rT   rU   rV   r   r”   Ú
_reallyDie)r5   r‚   s   &&r.   ÚforwardingPortDisconnectedÚ5ConchTestForwardingProcess.forwardingPortDisconnected×   s?   € ð ŒØ�‰×Ñ˜WÔ%Ø�‰×%Ñ%Ô'Ü×Ò˜!˜TŸ_™_Ö-r-   c                	ób   €  V P                   P                  R 4       R#   \         d     R# i ; i)ÚKILLN)rT   ÚsignalProcessr   r4   s   &r.   r™   Ú%ConchTestForwardingProcess._reallyDieâ   s+   € ð	Ø�N‰N×(Ñ(¨Ö0øÜ#ô 	Úð	ús   ‚ Ÿ.­.c                óX   € V P                  4       P                  V P                  4       R# )zt
Fire the Deferred at self.deferred with the data collected
from the L{ConchTestForwardingPort} connection, if any.
N)rg   rz   r‚   rN   s   &&r.   r{   Ú'ConchTestForwardingProcess.processEndedè   s   € ð
 	×ÑÓ×$Ñ$ T§[¡[Ö1r-   )r‚   rX   r_   r�   )r(   r)   r*   r+   r8   r_   rƒ   rg   rJ   rˆ   r�   rš   r™   r{   r,   r'   r-   r.   r   r   ¤   s6   † ñ
ð €Hòòòò
ò.ò	.òö2r-   r   c                  ó2   € ] tR t^ðtRtR tR tR tR tRt	R# )r�   z×
Connects to server launched by a third-party process (managed by
L{ConchTestForwardingProcess}) sends data, then reports whatever it
received back to the L{ConchTestForwardingProcess} once the connection
is ended.
c                ó   € Wn         W n        R# )zÀ
@type protocol: L{ConchTestForwardingProcess}
@param protocol: The L{ProcessProtocol} which made this connection.

@type data: str
@param data: The data to be sent to the third-party server.
N)r   rX   )r5   r   rX   s   &&&r.   rƒ   Ú ConchTestForwardingPort.__init__ø   s   € ð !ŒØŽ	r-   c                	ó^   € R V n         V P                  P                  V P                  4       R# )r-   N)r‚   rT   rU   rX   r4   s   &r.   rJ   Ú&ConchTestForwardingPort.connectionMade  s   € ØˆŒØ�‰×Ñ˜TŸY™YÖ'r-   c                	ó8   € V ;P                   V,          un         R # rc   )r‚   rW   s   &&r.   rY   Ú$ConchTestForwardingPort.dataReceived  s   € Ø�Š�tÕ�r-   c                	óP   € V P                   P                  V P                  4       R # rc   )r   rš   r‚   rN   s   &&r.   rP   Ú&ConchTestForwardingPort.connectionLost
  s   € Ø�‰×0Ñ0°·±Ö=r-   )r‚   rX   r   N)
r(   r)   r*   r+   r8   rƒ   rJ   rY   rP   r,   r'   r-   r.   r�   r�   ð   s   † ñò	ò(òö>r-   r�   c               ó$   € V ^8„  d   QhRRRRRR/# )é   Úargsz	list[str]ÚmodÚstrÚreturnzlist[bytes]r'   )rw   s   "r.   Ú__annotate__r±     s!   € ÷ >ñ >�Ið > Cð >°kñ >r-   c                ó†   € \         P                  R V,          .p. VOV O Uu. uF  q3P                  R4      NK  	  up# u upi )a$  -c
### Twisted Preamble
import sys, os
path = os.path.abspath(sys.argv[0])
while os.path.dirname(path) != path:
    if os.path.basename(path).startswith('Twisted'):
        sys.path.insert(0, path)
        break
    path = os.path.dirname(path)

from twisted.conch.scripts.%s import run
run()úutf-8)ÚsysÚ
executableÚencode)r­   r®   ÚstartÚeachs   &&  r.   Ú	_makeArgsr¹     sH   € ä�‰ð		ð õ	ð€Eð" .=¨u¨_°t©_Ó=©_ T�K‰K˜Ö ©_Ñ=Ð=ùÒ=s   ¢>c                  ó^   € ] tR tRt]'       g   Rt]R 4       tR tR t	R t
R tR R	 ltR
tR# )ÚConchServerSetupMixini#  zcan't run without cryptographyc                 	ó   € \        R 4      # )s   testuserr
   r'   r-   r.   ÚrealmFactoryÚ"ConchServerSetupMixin.realmFactory'  s   € ä˜kÓ*Ð*r-   c                	ó&  € R F@  p\         P                  P                  V4      '       g   K*  \         P                  ! V4       KB  	  \	        R R4      ;_uu_ 4       pVP                  \        4       RRR4       \	        RR4      ;_uu_ 4       pVP                  \        4       RRR4       \         P                  ! R R4       \        R 4      P                  4       pVP                  P                  '       g   VP                  P                  '       d   \        R4      h\	        RR4      ;_uu_ 4       pVP                  R\        ,           4       RRR4       R#   + '       g   i     Lð; i  + '       g   i     LÑ; i  + '       g   i     R# ; i)	Úrsa_testúrsa_test.pubÚkh_testÚwbNi€  zgprivate key readable by others despite chmod; possible windows permission issue? see https://tm.tl/9767s
   127.0.0.1 )rÀ   rÁ   rÂ   )ÚosÚpathÚexistsÚremoveÚopenrU   r   r	   Úchmodr   ÚgetPermissionsÚgroupÚreadÚotherr   )r5   r•   Úpermissionss   &  r.   Ú_createFilesÚ"ConchServerSetupMixin._createFiles+  s  € Û8ˆAÜ�w‰w�~‰~˜a× Ô Ü—	’	˜!–ñ 9ô �*˜d×#Ô# qØ�G‰GÔ&Ô'÷ $ä�. $×'Ô'¨1Ø�G‰GÔ%Ô&÷ (ä
�Š�˜UÔ#Ü˜zÓ*×9Ñ9Ó;ˆØ×Ñ×!×!Ð! [×%6Ñ%6×%;×%;Ð%;Üð*óð ô
 �)˜T×"Ô" aØ�G‰G�MÔ$5Õ5Ô6÷ #Ñ"÷ $×#úç'×'ú÷ #×"Ð"ús$   ÁEÂE,Ä2E?ÅE)	Å,E<	Å?F	c                	ó    € \         P                   ! 4       pVP                  R4       VP                  4       ^,          pVP                  4        V# )Ú )rÒ   r   )ÚsocketÚbindÚgetsocknameÚclose)r5   Úsr�   s   &  r.   Ú_getFreePortÚ"ConchServerSetupMixin._getFreePort>  s6   € Ü�MŠM‹OˆØ	�‰ˆwŒØ�}‰}‹˜qÕ!ˆØ	�‰Œ	Øˆr-   c                ó¤   € V P                  4       p\        P                  ! V4      pVP                  \	        4       4       \        4       pW#n        V# )zv
Make a L{ConchTestServerFactory}, which allows us to start a
L{ConchTestServer} -- i.e. an actually listening conch.
)r½   r   ÚPortalÚregisterCheckerr    r   )r5   ÚrealmÚpÚfactorys   &   r.   Ú_makeConchFactoryÚ'ConchServerSetupMixin._makeConchFactoryE  sD   € ð
 ×!Ñ!Ó#ˆÜ�MŠM˜%Ó ˆØ	×ÑÔ3Ó5Ô6Ü(Ó*ˆØŒØˆr-   c                	ó  € V P                  4        V P                  4       V n        ^V P                  n        \        P
                  ! ^ V P                  RR7      V n        \        P
                  ! ^ \        4       4      V n        V P                  P                  4       P                  V n        \        '       dR   \        P
                  ! ^ \        4       RR7      V n        V P                  P                  4       P                  V n        R# R# )é   r‹   )Ú	interfacez::1N)rÏ   rà   ÚconchFactoryÚexpectedLoseConnectionr   Ú	listenTCPÚconchServerr\   Ú
echoServerÚgetHostr�   ÚechoPortr   ÚechoServerV6Ú
echoPortV6r4   s   &r.   ÚsetUpÚConchServerSetupMixin.setUpQ  s¾   € Ø×ÑÔØ ×2Ñ2Ó4ˆÔØ34ˆ×ÑÔ0Ü"×,Ò,Øˆt× Ñ ¨Kô
ˆÔô "×+Ò+¨A¬{«}Ó=ˆŒØŸ™×/Ñ/Ó1×6Ñ6ˆŒß‹8Ü '× 1Ò 1°!´[³]ÈeÔ TˆDÔØ"×/Ñ/×7Ñ7Ó9×>Ñ>ˆDŽOñ r-   c               ó   € V ^8„  d   QhRR/# )r¬   r°   r   r'   )rw   s   "r.   r±   Ú"ConchServerSetupMixin.__annotate__^  s   € ÷ (ñ (˜#ñ (r-   c                	ó¾  €  ^V P                   P                  n        V P                   P                  P                  P	                  4        \        V P                  P                  4      \        V P                  P                  4      .p\        '       d/   VP                  \        V P                  P                  4      4       \        V4      #   \
         d     L�i ; i)rã   )rå   ÚprotoÚdonerT   rV   ÚAttributeErrorr   rè   ÚstopListeningré   r   Úappendrì   r   )r5   Ú	deferredss   & r.   ÚtearDownÚConchServerSetupMixin.tearDown^  s­   € ð	?Ø+,ˆD×Ñ×#Ñ#Ô(ð ×Ñ×#Ñ#×-Ñ-×<Ñ<Ô>ä˜$×*Ñ*×8Ñ8Ó9Ü˜$Ÿ/™/×7Ñ7Ó8ð
ˆ	÷ ‹8Ø×Ñœ]¨4×+<Ñ+<×+JÑ+JÓKÔLÜ˜YÓ'Ð'øô ô 	Ùð	ús   ‚C ÃCÃC)rå   rè   rë   rí   ré   rì   N)r(   r)   r*   r+   r!   rD   Ústaticmethodr½   rÏ   rØ   rà   rî   rù   r,   r'   r-   r.   r»   r»   #  s:   † ßØ/ˆàñ+ó ð+ò7ò&ò
ò?÷(ñ (r-   r»   c                  ó,   € ] tR tRtRtR tR tR tRtR# )ÚForwardingMixinio  a«  
Template class for tests of the Conch server's ability to forward arbitrary
protocols over SSH.

These tests are integration tests, not unit tests. They launch a Conch
server, a custom TCP server (just an L{EchoProtocol}) and then call
L{execute}.

L{execute} is implemented by subclasses of L{ForwardingMixin}. It should
cause an SSH client to connect to the Conch server, asking it to forward
data to the custom TCP server.
c                ón   € V P                  R\        4       4      pVP                  V P                  R4      # )z“
Test that we can use whatever client to send the command "echo goodbye"
to the Conch server. Make sure we receive "goodbye" back from the
server.
úecho goodbyeó   goodbye
©Úexecuter^   ÚaddCallbackÚassertEqualre   s   & r.   Ú	test_execÚForwardingMixin.test_exec}  s/   € ð �L‰L˜Ô)@Ó)BÓCˆØ�}‰}˜T×-Ñ-¨|Ó<Ð<r-   c                óÂ   € V P                  4       p\        VR4      pV P                  RVRWP                  3,          R7      pVP	                  V P
                  R4       V# )za
Test that we can use whatever client to forward a local port to a
specified port on the server.
ó   test
rÒ   z-N -L%i:127.0.0.1:%i©ÚsshArgs©rØ   r   r  rë   r  r  ©r5   Ú	localPortÚprocessrf   s   &   r.   Útest_localToRemoteForwardingÚ,ForwardingMixin.test_localToRemoteForwarding†  s`   € ð
 ×%Ñ%Ó'ˆ	Ü,¨Y¸	ÓBˆØ�L‰LØ�Ð!7¸9ÇmÁmÐ:TÕ!Tð ó 
ˆð 	
�‰�d×&Ñ&¨	Ô2Øˆr-   c                óÂ   € V P                  4       p\        VR4      pV P                  RVRWP                  3,          R7      pVP	                  V P
                  R4       V# )z[
Test that we can use whatever client to forward a port from the server
to a port locally.
r  rÒ   z-N -R %i:127.0.0.1:%ir	  r  r  s   &   r.   Útest_remoteToLocalForwardingÚ,ForwardingMixin.test_remoteToLocalForwarding“  s`   € ð
 ×%Ñ%Ó'ˆ	Ü,¨Y¸	ÓBˆØ�L‰LØ�Ð!8¸IÇ}Á}Ð;UÕ!Uð ó 
ˆð 	
�‰�d×&Ñ&¨	Ô2Øˆr-   r'   N)	r(   r)   r*   r+   r8   r  r  r  r,   r'   r-   r.   rý   rý   o  s   † ñò=òör-   rý   c                  óD   € ] tR tRtRtR tR tR tR tR t	R t
R	 tR
tR# )ÚRekeyAvatari¥  a  
This avatar implements a shell which sends 60 numbered lines to whatever
connects to it, then closes the session with a 0 exit status.

60 lines is selected as being enough to send more than 2kB of traffic, the
amount the client is configured to initiate a rekey after.
c                	óX   € \         P                  ! V 4       \        V P                  R &   R# )s   sessionN)r"   rƒ   r$   ÚchannelLookupr4   s   &r.   rƒ   ÚRekeyAvatar.__init__¯  s    € Ü×Ò˜4Ô Ü)3ˆ×Ñ˜:Ó&r-   c                óâ   aa€ \         P                  ! 4       pVP                  S4       SP                  \        V4      4       VV3R lp\	        V\        4       4      oSP                  R4       R# )z5
Write 60 lines of data to the transport, then exit.
c                ó*  <€ \        V 4      pV^<8X  dT   SP                  4        SP                  P                  P	                  SP                  RR4       SP                  4        R# RV3,          pVP                  R4      pSP                  V4       R# )é<   s   exit-statuss       zline #%02d
r³   N)ÚnextÚstopÚsessionÚconnÚsendRequestrV   r¶   rU   )ÚcounterÚiÚlineÚcallrT   s   &  €€r.   rU   Ú$RekeyAvatar.openShell.<locals>.write½  sx   ø€ Ü�W“ˆAØ�BŒwØ—	‘	”Ø×!Ñ!×&Ñ&×2Ñ2Ø×%Ñ% ~Ð7Jôð ×(Ñ(Ö*à%¨¨Õ,�Ø—{‘{ 7Ó+�Ø—‘ Ö%r-   g{®Gáz„?N)r   ÚProtocolÚmakeConnectionr%   r   r   r·   )r5   rT   ró   rU   r$  s   &f  @r.   Ú	openShellÚRekeyAvatar.openShell³  sU   ù€ ô ×!Ò!Ó#ˆØ×Ñ˜YÔ'Ø× Ñ ¤¨eÓ!4Ô5ö	&ô( ˜5¤%£'Ó*ˆØ�
‰
�4Ör-   c                ó   € R# )z"
Ignore the close of the session.
Nr'   r4   s   &r.   ÚclosedÚRekeyAvatar.closedÔ  s   ‚ r-   c                	ó   € R # rc   r'   r4   s   &r.   r>   ÚRekeyAvatar.eofReceivedÙ  ó   € ár-   c                	ó   € R # rc   r'   )r5   ró   Úcommands   &&&r.   ÚexecCommandÚRekeyAvatar.execCommandÝ  r/  r-   c                	ó   € R # rc   r'   )r5   ÚtermÚ
windowSizeÚmodess   &&&&r.   ÚgetPtyÚRekeyAvatar.getPtyá  r/  r-   c                	ó   € R # rc   r'   )r5   ÚnewWindowSizes   &&r.   ÚwindowChangedÚRekeyAvatar.windowChangedå  r/  r-   r'   N)r(   r)   r*   r+   r8   rƒ   r(  r+  r>   r2  r8  r<  r,   r'   r-   r.   r  r  ¥  s+   † ñò4òòBò
òòör-   r  c                  ó    € ] tR tRtRtR tRtR# )Ú
RekeyRealmiê  zK
This realm gives out new L{RekeyAvatar} instances for any avatar request.
c                	ó,   € V^ ,          \        4       R 3# )r   c                 ó   € R # rc   r'   r'   r-   r.   Ú<lambda>Ú*RekeyRealm.requestAvatar.<locals>.<lambda>ð  s   € ±Tr-   )r  )r5   ÚavatarIDÚmindÚ
interfacess   &&&*r.   ÚrequestAvatarÚRekeyRealm.requestAvatarï  s   € Ø˜!�}œk›m©\Ð9Ð9r-   r'   N)r(   r)   r*   r+   r8   rG  r,   r'   r-   r.   r?  r?  ê  s   † ñö:r-   r?  c                  ó$   € ] tR tRtRt]tR tRtR# )ÚRekeyTestsMixinió  zd
TestCase mixin which defines tests exercising L{SSHTransportBase}'s handling
of rekeying messages.
c                óp   a € \        4       pS P                  RVR4      pV 3R lpVP                  V4       V# )zo
After a client-initiated rekey is completed, application data continues
to be passed over the SSH connection.
rÒ   z-o RekeyLimit=2Kc                óÈ   <€ R P                  \        ^<4       Uu. uF  pRV3,          NK  	  up4      R ,           pVP                  R4      pSP                  W4       R# u upi )Ú
z
line #%02dr³   N)ÚjoinÚranger¶   r  )Úresultr"  ÚexpectedResultr5   s   &  €r.   ÚfinishedÚ2RekeyTestsMixin.test_clientRekey.<locals>.finished  sX   ø€ Ø!ŸY™YÄUÈ2ÄYÓ'OÁYÀ¨¸°t×(;Ð(;ÁYÑ'OÓPÐSWÕWˆNØ+×2Ñ2°7Ó;ˆNØ×Ñ˜VÖ4ùò (Ps   šA)r^   r  r  )r5   r  rf   rR  s   f   r.   Útest_clientRekeyÚ RekeyTestsMixin.test_clientRekeyû  s8   ø€ ô
 *Ó+ˆØ�L‰L˜˜WÐ&8Ó9ˆõ	5ð
 	
�‰�hÔØˆr-   r'   N)	r(   r)   r*   r+   r8   r?  r½   rT  r,   r'   r-   r.   rJ  rJ  ó  s   † ñð
 €Lör-   rJ  c                  óF   € ] tR tRt]! R4      '       g   RtRR R lltRtR# )	ÚOpenSSHClientMixini  Ússhz$no ssh command-line client availablec               ó(   € V ^8„  d   QhRRRRRRRR/# )r¬   ÚremoteCommandr¯   r  r^   r
  r°   úDeferred[None]r'   )rw   s   "r.   r±   ÚOpenSSHClientMixin.__annotate__  s,   € ÷ -ñ -Ø ð-Ø+Bð-ØMPð-à	ñ-r-   c                ó~  € \        4       ;qBn        RV,           R,           V,           pV P                  P                  4       P                  pWV,          P                  4       p. pV F#  p	VP                  V	P                  R4      4       K%  	  \        \        4      P                  V\        R4      ^ ,          V4       V# )ah  
Connects to the SSH server started in L{ConchServerSetupMixin.setUp} by
running the 'ssh' command line tool.

@type remoteCommand: str
@param remoteCommand: The command (with arguments) to run on the
remote end.

@type process: L{ConchTestOpenSSHProcess}

@type sshArgs: str
@param sshArgs: Arguments to pass to the 'ssh' process.

@return: L{defer.Deferred}
zŸssh -2 -l testuser -p %i -F /dev/null -oIdentitiesOnly=yes -oUserKnownHostsFile=kh_test -oPasswordAuthentication=no -oHostKeyAlgorithms=ssh-rsa -a -i rsa_test z 127.0.0.1 r³   rX  )r   r_   rè   rê   r�   Úsplitr÷   r¶   r   r   ÚspawnProcessr   )
r5   rZ  r  r
  rP  Úcmdliner�   ÚcmdsÚencodedCmdsÚcmds
   &&&&      r.   r  ÚOpenSSHClientMixin.execute  s¯   € ô& %-£JÐ.ˆÔ!ðð õð õð õð 	ð  ×$Ñ$×,Ñ,Ó.×3Ñ3ˆØ•×%Ñ%Ó'ˆØˆÛˆCØ×Ñ˜sŸz™z¨'Ó2Ö3ñ äœÓ ×-Ñ-¨g´u¸U³|ÀAµÈÔTØˆr-   r'   N)rÒ   )r(   r)   r*   r+   r   rD   r  r,   r'   r-   r.   rW  rW    s   † Ù��<Š<Ø5ˆ÷-ó -r-   rW  c                  óJ   € ] tR tRtRtR tR tR tR tR t	R t
R	 tR
 tRtR# )ÚOpenSSHKeyExchangeTestsi@  zP
Tests L{SSHTransportBase}'s key exchange algorithm compatibility with
OpenSSH.
c                ó®  € . p \         P                  ! \        R4      ^ ,          RR.\         P                  R7      p\	        V\
        4      '       g   VP                  R4      pVP                  4       pW9  d   \        V R24      hV P                  R\        4       RV,           4      pVP                  V P                  R	4      #   \         d     L_i ; i)
a  
Call execute() method of L{OpenSSHClientMixin} with an ssh option that
forces the exclusive use of the key exchange algorithm specified by
keyExchangeAlgo

@type keyExchangeAlgo: L{str}
@param keyExchangeAlgo: The key exchange algorithm to use

@return: L{defer.Deferred}
rX  z-QÚkex)Ústderrr³   z not supported by ssh clientz
echo helloz-oKexAlgorithms=s   hello
)Ú
subprocessÚcheck_outputr   ÚSTDOUTÚ
isinstancer¯   rx   r^  ÚBaseExceptionr   r  r^   r  r  )r5   ÚkeyExchangeAlgoÚkexAlgorithmsÚoutputrf   s   &&   r.   ÚassertExecuteWithKexAlgorithmÚ5OpenSSHKeyExchangeTests.assertExecuteWithKexAlgorithmF  sÈ   € ð ˆð	Ü×,Ò,Ü�u“˜a• $¨Ð.´z×7HÑ7HôˆFô ˜f¤c×*Ò*ØŸ™ wÓ/�Ø"ŸL™L›NˆMð Ô/Ü˜oÐ.Ð.JÐKÓLÐLà�L‰LØÜ#Ó%Ø Õ0ó
ˆð
 �}‰}˜T×-Ñ-¨zÓ:Ð:øô ô 	Ùð	ús   „A0C ÃCÃCc                ó$   € V P                  R4      # )zJ
The ecdh-sha2-nistp256 key exchange algorithm is compatible with
OpenSSH
zecdh-sha2-nistp256©rr  r4   s   &r.   Útest_ECDHSHA256Ú'OpenSSHKeyExchangeTests.test_ECDHSHA256f  ó   € ð
 ×1Ñ1Ð2FÓGÐGr-   c                ó$   € V P                  R4      # )zJ
The ecdh-sha2-nistp384 key exchange algorithm is compatible with
OpenSSH
zecdh-sha2-nistp384ru  r4   s   &r.   Útest_ECDHSHA384Ú'OpenSSHKeyExchangeTests.test_ECDHSHA384m  rx  r-   c                ó$   € V P                  R4      # )zJ
The ecdh-sha2-nistp521 key exchange algorithm is compatible with
OpenSSH
zecdh-sha2-nistp521ru  r4   s   &r.   Útest_ECDHSHA521Ú'OpenSSHKeyExchangeTests.test_ECDHSHA521t  rx  r-   c                ó$   € V P                  R4      # )zT
The diffie-hellman-group14-sha1 key exchange algorithm is compatible
with OpenSSH.
zdiffie-hellman-group14-sha1ru  r4   s   &r.   Útest_DH_GROUP14Ú'OpenSSHKeyExchangeTests.test_DH_GROUP14{  s   € ð
 ×1Ñ1Ð2OÓPÐPr-   c                ó$   € V P                  R4      # )z[
The diffie-hellman-group-exchange-sha1 key exchange algorithm is
compatible with OpenSSH.
z"diffie-hellman-group-exchange-sha1ru  r4   s   &r.   Útest_DH_GROUP_EXCHANGE_SHA1Ú3OpenSSHKeyExchangeTests.test_DH_GROUP_EXCHANGE_SHA1‚  s   € ð
 ×1Ñ1Ð2VÓWÐWr-   c                ó$   € V P                  R4      # )z]
The diffie-hellman-group-exchange-sha256 key exchange algorithm is
compatible with OpenSSH.
z$diffie-hellman-group-exchange-sha256ru  r4   s   &r.   Útest_DH_GROUP_EXCHANGE_SHA256Ú5OpenSSHKeyExchangeTests.test_DH_GROUP_EXCHANGE_SHA256‰  s   € ð
 ×1Ñ1Ø2ó
ð 	
r-   c                óH   € V P                  \        V P                  R4       R# )za
The list of key exchange algorithms supported
by OpenSSH client is obtained with C{ssh -Q kex}.
zunsupported-algorithmN)ÚassertRaisesr   rr  r4   s   &r.   Útest_unsupported_algorithmÚ2OpenSSHKeyExchangeTests.test_unsupported_algorithm’  s    € ð
 	×ÑÜ�d×8Ñ8Ð:Qö	
r-   r'   N)r(   r)   r*   r+   r8   rr  rv  rz  r}  r€  rƒ  r†  rŠ  r,   r'   r-   r.   rf  rf  @  s5   † ñò
;ò@HòHòHòQòXò
ö
r-   rf  c                  ó*   € ] tR tRtRt]R 4       tRtR# )ÚOpenSSHClientForwardingTestsiœ  zJ
Connection forwarding tests run against the OpenSSL command line client.
c                óÂ   € V P                  4       p\        VR4      pV P                  RVRWP                  3,          R7      pVP	                  V P
                  R4       V# )z7
Forwarding of arbitrary IPv6 TCP connections via SSH.
r  rÒ   z-N -L%i:[::1]:%ir	  )rØ   r   r  rí   r  r  r  s   &   r.   Útest_localToRemoteForwardingV6Ú;OpenSSHClientForwardingTests.test_localToRemoteForwardingV6¡  s`   € ð
 ×%Ñ%Ó'ˆ	Ü,¨Y¸	ÓBˆØ�L‰LØ�Ð!3°yÇ/Á/Ð6RÕ!Rð ó 
ˆð 	
�‰�d×&Ñ&¨	Ô2Øˆr-   r'   N)r(   r)   r*   r+   r8   r   r�  r,   r'   r-   r.   r�  r�  œ  s   † ñð ñ
ó ô
r-   r�  c                  ó   € ] tR tRtRtRtR# )ÚOpenSSHClientRekeyTestsi¯  z=
Rekeying tests run against the OpenSSL command line client.
r'   N)r(   r)   r*   r+   r8   r,   r'   r-   r.   r’  r’  ¯  s   † õr-   r’  c                  ó€   € ] tR tRtRt]P                  R8X  d   RtRR R lltR t	R	 t
R
 R ltR R ltR R ltRtR# )ÚCmdLineClientTestsiµ  zH
Connection forwarding tests run against the Conch command line client.
Úwin32z!can't run cmdline client on win32Nc               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r¬   rZ  r¯   r  r^   r
  Ú	conchArgszlist[str] | NoneÚ
remoteHostr°   r[  r'   )rw   s   "r.   r±   ÚCmdLineClientTests.__annotate__½  sF   € ÷  ñ  àð ð )ð ð ð	 ð
 $ð ð ð ð 
ñ r-   c                ó,  € Vf   . p\        4       Vn        V P                  P                  4       P                  pRP                  V4      V,           RV R2,           V,           p\        VP                  4       4      p\        P                  P                  4       p	\        P                  P                  \        P                  4      V	R&   \        \         4      P#                  V\        P$                  \'        WH,           4      V	R7       VP                  # )zc
As for L{OpenSSHClientTestCase.execute}, except it runs the 'conch'
command line tool, not 'ssh'.
z[-p {} -l testuser --known-hosts kh_test --user-authentications publickey -a -i rsa_test -v Ú Ú
PYTHONPATH)Úenv)r   r_   rè   rê   r�   rw   Úlistr^  rÄ   ÚenvironÚcopyÚpathseprN  r´   rÅ   r   r   r_  rµ   r¹   )
r5   rZ  r  r
  r—  r˜  r�   Úcmdtemplater^  r�  s
   &&&&&&    r.   r  ÚCmdLineClientTests.execute½  sê   € ð ÒØˆIä#›:ˆÔØ×Ñ×'Ñ'Ó)×.Ñ.ˆð÷
 ‘&˜“, õ)ð
 ./¨z¨l¸!Ð+<õ=ð
 @MõMð 	ô �[×&Ñ&Ó(Ó)ˆÜ�j‰j�o‰oÓˆÜŸJ™JŸO™O¬C¯H©HÓ5ˆˆLÑÜœÓ ×-Ñ-Ø”S—^‘^¤Y¨yÕ/@Ó%AÀsð 	.ô 	
ð ×ÑÐr-   c           	     ó  a a€ VV 3R lp\         P                  ! S P                  4       4      oS P                  R\	        4       RRSP
                  RR.R7      pVP                  S P                  R4       VP                  V4       V# )	z$
It can store logs to a local file.
c                óL   <€ SP                  4       pSP                  R V4       R# )s   Log opened.N)Ú
getContentÚassertIn)rP  Ú
logContentÚlogPathr5   s   & €€r.   Úcb_check_logÚ<CmdLineClientTests.test_runWithLogFile.<locals>.cb_check_logã  s   ø€ Ø ×+Ñ+Ó-ˆJØ�M‰M˜.¨*Ö5r-   rÿ   z--logz	--logfilez--host-key-algorithmszssh-rsa©rZ  r  r—  r   )r   r   Úmktempr  r^   rÅ   r  r  )r5   rª  rf   r©  s   f  @r.   Útest_runWithLogFileÚ&CmdLineClientTests.test_runWithLogFileÞ  s{   ù€ ö
	6ô ×#Ò# D§K¡K£MÓ2ˆà�L‰LØ(Ü+Ó-àØØ—‘Ø'Øðð ó 

ˆð 	
�‰�d×&Ñ&¨Ô5Ø	�‰�lÔ#Øˆr-   c                ót   € V P                  R\        4       R7      pVP                  V P                  R4       V# )z8
Do not use --host-key-algorithms flag on command line.
rÿ   )rZ  r  r   r  re   s   & r.   Ú%test_runWithNoHostAlgorithmsSpecifiedÚ8CmdLineClientTests.test_runWithNoHostAlgorithmsSpecifiedù  s;   € ð �L‰LØ(Ô2IÓ2Kð ó 
ˆð 	
�‰�d×&Ñ&¨Ô5Øˆr-   c               ó   € V ^8„  d   QhRR/# ©r¬   r°   r[  r'   )rw   s   "r.   r±   r™    s   € ÷ 9ñ 9°.ñ 9r-   c                óp   € V P                  R\        4       R.R7      P                  V P                  R4      # )zC
Simple smoke test for '--compress' flag to ensure we can connect.
zecho compressedz
--compressr¬  s   compressed
r  r4   s   &r.   Ú test_runWithCompressionSpecifiedÚ3CmdLineClientTests.test_runWithCompressionSpecified  s<   € ð �|‰|Ø+Ü+Ó-Ø#�nð ó 
÷ ‰+�d×&Ñ&¨Ó
8ð		9r-   c               ó   € V ^8„  d   QhRR/# r´  r'   )rw   s   "r.   r±   r™    s   € ÷ 

ñ 

¨>ñ 

r-   c                óL   € \        4       p^Vn        V P                  RVRR7      # )z,
Connecting to an invalid host should fail.
zecho nonfunctionalúnowhere.invalid©rZ  r  r˜  )r^   ra   r  ©r5   ÚexpectErrors   & r.   Útest_connectToInvalidHostÚ,CmdLineClientTests.test_connectToInvalidHost  s3   € ô .Ó/ˆØ'(ˆÔ$Ø�|‰|Ø.ØØ(ð ó 
ð 	
r-   c               ó   € V ^8„  d   QhRR/# r´  r'   )rw   s   "r.   r±   r™    s   € ÷ 
ñ 
 .ñ 
r-   c                óf   € \        4       pV P                  V P                  RVRR7      \        4      # )zU
L{ConchTestOpenSSHProcess} fails with a L{ConchError} if an expectation
is not met.
zecho checkfailurerº  r»  )r^   ÚassertFailurer  r   r¼  s   & r.   Útest_testFailureÚ#CmdLineClientTests.test_testFailure  s>   € ô
 .Ó/ˆØ×!Ñ!Ø�L‰LØ1Ø#Ø,ð ó ô
 ó
ð 	
r-   r'   )rÒ   Nr‹   )r(   r)   r*   r+   r8   r   ÚplatformTyperD   r  r®  r±  r¶  r¾  rÃ  r,   r'   r-   r.   r”  r”  µ  s@   † ñð ×Ñ˜wÔ&Ø2ˆ÷ òBò6	õ9õ

÷
ñ 
r-   r”  )Úconch)XÚ
__future__r   rÄ   rÓ   rj  r´   Ú	itertoolsr   Útypingr   Úzope.interfacer   Útwisted.conch.errorr   Útwisted.conch.test.keydatar   r	   Útwisted.conch.test.test_sshr   Útwisted.credr   Útwisted.internetr   r   Útwisted.internet.deferr   r   r   Útwisted.internet.errorr   Útwisted.internet.interfacesr   Útwisted.internet.taskr   Útwisted.pythonr   r   r   Útwisted.python.filepathr   Útwisted.python.procutilsr   Útwisted.python.reflectr   Útwisted.test.testutilsr   r   Útwisted.trial.unittestr   r   r   r    ÚImportErrorr!   Útwisted.conch.avatarr"   Útwisted.conch.ssh.sessionr#   r$   r%   Útwisted.conch.interfacesÚtwisted.conch.scripts.conchÚ_StdioInteractingSessionr<   Úer¯   rC   r0   r:   r&  rF   ÚFactoryr\   ÚProcessProtocolr^   r   r�   r¹   r»   rý   r  r?  rJ  rW  rf  r�  r’  r”  r'   r-   r.   Ú<module>rã     sê  ðõ #ã 	Û Û Û 
Ý Ý å &å *ß LÝ 6Ý ß .ß IÑ IÝ 7Ý 7Ý -ß 1Ñ 1Ý ,Ý *Ý 0ß <ß 5ð	÷ñ ˜^Ó,€çÝ.ßLÒLå1÷ñ ð7ÝRð 7Ð÷"ñ "ô$- 8ô -ô(
,ˆ8×Ñô 
,ô�(×"Ñ"ô ô-.˜h×6Ñ6ô -.ô`I2 ×!9Ñ!9ô I2ôX>˜h×/Ñ/ô >÷<>÷*I(ñ I(ôX/Ð+ô /ñl ˆXÓôA�)ó Aó ðA÷H:ñ :ôÐ+ô ÷21ñ 1ôhY
Ð3Ð5GÈô Y
ôx ?Ð4FÈô ô&˜oÐ/AÀ8ô ôr
˜¨(ö r
øðc ô 	Úð	ûð" ô 
Ø"ÐÙ�!‹f€GÞ	ûð
ús*   ÂG ÃG) ÇG&Ç%G&Ç)HÇ0HÈH