
    6hE                       S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	J
r
JrJrJr  \R                  r\R                  rSrS=q=qq0 r\R*                  " \5      r\" SS	S
S9  \" SSSS9  \" SSSS9  S rS rS r\" \5      S 5       rS rg)a  http authentication with factotum

This extension allows the factotum(4) facility on Plan 9 from Bell Labs
platforms to provide authentication information for HTTP access. Configuration
entries specified in the auth section as well as authentication information
provided in the repository URL are fully supported. If no prefix is specified,
a value of "*" will be assumed.

By default, keys are specified as::

  proto=pass service=hg prefix=<prefix> user=<username> !password=<password>

If the factotum extension is unable to read the required key, one will be
requested interactively.

A configuration section is available to customize runtime behavior. By
default, these entries are::

  [factotum]
  executable = /bin/auth/factotum
  mountpoint = /mnt/factotum
  service = hg

The executable entry defines the full path to the factotum binary. The
mountpoint entry defines the path to the factotum file service. Lastly, the
service entry controls the service name used when reading keys.

    )annotationsN)_)procutil)errorhttpconnection	registrarurlutil      factotum
   executables   /bin/auth/factotum)default
   mountpoints   /mnt/factotum   services   hgc                   U R                   R                  5       (       d  [        R                  " [	        S5      5      eSU;  a  SU-  nSU-  n[
        R                  " [        R                  " S[        U4-  5      5        g )Ns   factotum not interactives   user=s   %s user?s   %s !password?s
   %s -g '%s')
uiinteractiver   Abortr   ossystemr   tonativestr_executable)selfparamss     0/usr/lib/python3/dist-packages/hgext/factotum.pyauth_getkeyr   X   sg    77  kk!7899vv%&FIIh""=K3H#HIJ    c                \   SU-  n [         R                  " S[        -  [         R                  5      n [         R                  " USU-  5        [         R
                  " U[        5      R                  5       nUS   S:X  a  [         R                  " US5        [         R
                  " U[        5      R                  S S5      u  pVnUS:X  az  UR                  S5      (       aK  UR                  S5      (       a  US	S
 R                  SS5      nO[        R                  " [        S5      5      eXg4[         R                  " U5        $ [         R                  " U5        U" X5        GM_  ! [         a     [        R                  " [        S5      5      ef = f! [         R                  " U5        f = f)Ns   proto=pass %ss   %s/rpcs   start %sr   s   oks   read      '   s   ''s   malformed password strings   factotum not responding)r   open_mountpointO_RDWRwritereadERRMAXsplit
startswithendswithreplacer   r   r   closeOSError)r   getkeyr   fdlstatususerpasswds           r   auth_getuserpasswdr5   a   sE   &F
WWY,bii8	HHRv-.F#))+Atu}W%')wwr6':'@'@q'I$fU?((..!??400%+Ab\%9%9%%FF"'++a0L.M"NN > HHRLBHHRLt'   	=++a :;<<	= HHRLs   C:E& &*FF F+c                   ^  U 4S jnU$ )Nc                6   > [        TU R                  U 5        U $ )N)setattr__name__)funcclss    r   	decorator%monkeypatch_method.<locals>.decoratorz   s    T]]D)r    )r;   r<   s   ` r   monkeypatch_methodr?   y   s     r   c                P   U R                   R                  X5      u  p4U(       a  U(       a  U R                  X45        X44$ Sn[        R                  " U R
                  X#5      nU(       a6  Uu  pxUR                  S5      nUR                  S5      UR                  S5      pCU(       a  U(       dT  U(       d"  UR                  S5      S   R                  5       nS[        U4-  n	U(       a  SX4-  n	[        U [        U	5      u  p4U R                  XX45        U R                  X45        X44$ )	Nr   s   prefixs   usernames   password    r   s   service=%s prefix=%ss
   %s user=%s)passwddbfind_user_password_writedebugr   readauthforurir   getr)   lower_servicer5   r   add_password)
r   realmauthurir3   r4   prefixresr   authr   s
             r   rC   rC      s    ==33ECLD&~F

'
'
?C
)$xx,dhh{.Cfv[[&q)//1F(Hf+=="f^3F)$VDed3T">r   c                p    U R                  SS5      qU R                  SS5      qU R                  SS5      qg )Nr   r   r   r   )configr   r$   rH   )r   s    r   uisetuprQ      s2    ))K7K))K7Kyyj1Hr   )__doc__
__future__r   r   mercurial.i18nr   mercurial.utilsr   	mercurialr   r   r   r	   r
   urlreqpasswordmgrr(   r   r$   rH   configtable
configitemr   r5   r?   rC   rQ   r>   r   r   <module>r[      s   &: # 	  $  
oo	'+ + +kH!!+.
 
!
 
 K0 K  !22r   