
    h                     N   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	J
r
Jr  SSKJr  SSKJrJrJrJr  \R&                  " S5      R(                  r\R*                  " \5      rSr\R2                  " 5       SS\S\S\4S	 jj5       r " S
 S5      r " S S\\5      rg)    N)MappingSequence   )
ssh_errors)InteractionAgentInteractionErrorInteractionHandlerwrite_askpass_to_tmpdirfeatureteststrreturnc                      [         R                  " SSU  SU 3SS/[         R                  S9  g! [         R                   a     gf = f)	Nssh-o z-Gnonexisting)stderrTF)
subprocesscheck_outputDEVNULLCalledProcessError)r   r   s     ?/usr/lib/python3/dist-packages/cockpit/_vendor/ferny/session.pyhas_featurer   %   sO    "WIQwi(@$ V_i_q_qr(( s   -0 AAc                   X    \ rS rSrS\\   S\\   4S jrS\\\4   S\\\4   4S jrSr	g)	SubprocessContext.   argsr   c                     U$ )ax  Return the args required to launch a process in the given context.

For example, this might return a vector with
    ["sudo"]
or
    ["flatpak-spawn", "--host"]
prepended.

It is also possible that more substantial changes may be performed.

This function is not permitted to modify its argument, although it may
(optionally) return it unmodified, if no changes are required.
 selfr   s     r   wrap_subprocess_args&SubprocessContext.wrap_subprocess_args/   s	         envc                     U$ )a:  Return the envp required to launch a process in the given context.

For example, this might set the "SUDO_ASKPASS" environment variable, if
needed.

As with wrap_subprocess_args(), this function is not permitted to
modify its argument, although it may (optionally) return it unmodified
if no changes are required.
r   )r!   r%   s     r   wrap_subprocess_env%SubprocessContext.wrap_subprocess_env?   s	     
r$   r   N)
__name__
__module____qualname____firstlineno__r   strr"   r   r'   __static_attributes__r   r$   r   r   r   .   sB    # 8C=  
wsCx'8 
WS#X=N 
r$   r   c                       \ rS rSr% SrS\S'   SrS\S'   SrS\S'           SS	\S
\	SSSSSSSSSSSSSSSS4S jjr
S\	4S jrSS jrSS jrSS jrS\\   S\\   4S jrSrg) SessionL   Nz"tempfile.TemporaryDirectory | None_controldirz
str | None_controlsockz!asyncio.subprocess.Process | None_processdestinationhandle_host_key
configfileidentity_file
login_nameoptionszMapping[str, str] | Nonepkcs11portz
int | Noneinteraction_responderzInteractionHandler | Noner   c
           
        #    [         R                  R                  [         R                  R	                  SS5      S5      n
[         R
                  " U
SS9  [        R                  " U
S9U l        U R                  R                   S3U l
        [        U R                  R                  5      n[        [         R                  5      nXS'   S	US
'   SUS'   SSSU R                  SSSSU 3/nUb  UR                  SU 35        Ub  UR                  SU 35        Ub"  U H  nUR                  SU SXn    35        M     Ub  UR                  SU 35        Ub  UR                  SU 35        Ub  UR                  SU 35        U(       a)  [        S5      (       a  UR                  SSU S3SS/5        [!        U	b  U	/O/ 5      n["        R$                  " S/UQUP7US["        R&                  R(                  ["        R&                  R(                  US S.6I S h  vN n UR+                  5       I S h  vN   [         R                  R-                  U R                  5      (       d   eUU l        g  NU N>! [0         a>  nUR3                  5       I S h  vN    [4        R6                  " [9        U5      5      S eS nAf[:         a=     UR=                  5         O! [>         a     Of = fUR3                  5       I S h  vN    e f = f7f) NXDG_RUNTIME_DIRz/runfernyT)exist_ok)dirz/socketSSH_ASKPASSforceSSH_ASKPASS_REQUIRE-DISPLAYz-Mz-N-Sr   zPermitLocalCommand=yeszLocalCommand=z-Fz-ir   z-Iz-pz-lKnownHostsCommandzKnownHostsCommand=z %I %H %t %K %fzStrictHostKeyChecking=yesz/usr/bin/sshc                  >    [        [        [        R                  5      $ N)prctlPR_SET_PDEATHSIGsignalSIGKILLr   r$   r   <lambda>!Session.connect.<locals>.<lambda>   s    u%5v~~Fr$   )r%   start_new_sessionstdinstdoutr   
preexec_fn) ospathjoinenvirongetmakedirstempfileTemporaryDirectoryr2   namer3   r
   dictappendr   extendr   asynciocreate_subprocess_execr   r   communicateexistsr4   r   waitr   get_exception_for_ssh_stderrr-   BaseExceptionkillProcessLookupError)r!   r5   r6   r7   r8   r9   r:   r;   r<   r=   rundiraskpass_pathr%   r   keyagentprocessexcs                     r   connectSession.connectT   s     bjjnn->GQ
FT*#666B#//445W= /t/?/?/D/DE2::)M%,!"I $##*M,0
 !KK"ZL)*$KK"]O,-bQw|n56  KK"VH&KK"TF$!KK"ZL)*{+>??KK*<.H1 
 !<Q<]"7!8cef  661t1[1s"'*<*<*D*D%%--eF	H H	##%%%77>>$"3"34444#DMH &   	N,,.  99#c(CM 
	
% ,,.  
	s   HLI.LI2 1I02;I2 -L0I2 2
K?<J5J%J55K?KK?
K!K? K!!K?7K:8K??Lc                     U R                   S L$ rK   )r4   r!   s    r   is_connectedSession.is_connected   s    }}D((r$   c                 r   #    U R                   c   eU R                   R                  5       I S h  vN   g  N7frK   )r4   rf   rt   s    r   rf   Session.wait   s+     }}(((mm  """s   -757c                 V    U R                   c   eU R                   R                  5         g rK   )r4   	terminatert   s    r   exitSession.exit   s"    }}(((!r$   c                 `   #    U R                  5         U R                  5       I S h  vN   g  N7frK   )r{   rf   rt   s    r   
disconnectSession.disconnect   s     		iiks   $.,.r   c                 v    U R                   c   eSSU R                   S/[        [        R                  U5      Q7$ )Nr   rH    )r3   mapshlexquoter    s     r   r"   Session.wrap_subprocess_args   s;      ,,, tT..LSd5KLLr$   )r2   r3   r4   )FNNNNNNN)r   N)r)   r*   r+   r,   r2   __annotations__r3   r4   r-   boolrq   ru   rf   r{   r~   r   r"   r.   r   r$   r   r0   r0   L   s    8<K5<!%L,% 59H18 /4154815<@-1+/KOX#&X'+X #/X &2	X
 #/X  :X +X )X .IX UYXt)d )#"
M# M8C= Mr$   r0   )x)rb   ctypes	functoolsloggingrV   r   rN   r   r\   typingr   r   r   r   interaction_agentr   r   r	   r
   CDLLrL   	getLoggerr)   loggerrM   	lru_cacher-   r   r   r   r0   r   r$   r   <module>r      s   $     	     $  n nD			8	$   s T   <zM!3 zMr$   