��c@s�dZddlmZddlmZddlmZmZddlZddl Z dZ
d�Zd�Zd �Z
e
e�d
��Zd�ZdS(s�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.
i�(t_(tpasswordmgr(thttpconnectiontutilNi�cCse|jj�s'tjtd���nd|kr@d|}nd|}tjdt|f�dS(Nsfactotum not interactivesuser=s%s user?s
%s !password?s
%s -g '%s'(tuitinteractiveRtAbortRtostsystemt_executable(tselftparams((s2/sys/lib/python2.7/site-packages/hgext/factotum.pytauth_getkey7s
cCsd|}x�rtjdttj�}z�y�tj|d|�tj|t�j�}|ddkr�tj|d�tj|t�j�}|ddkr�|dSnWn,t t
fk
r�tjt
d���nXWdtj|�X|||�q
WdS( Ns
proto=pass %ss%s/rpcsstart %sitoktreadisfactotum not responding(tTrueRtopent_mountpointtO_RDWRtwriteRtERRMAXtsplittOSErrortIOErrorRRRtclose(R
tgetkeyRtfdtl((s2/sys/lib/python2.7/site-packages/hgext/factotum.pytauth_getuserpasswd?s
cs�fd�}|S(Ncst�|j|�|S(N(tsetattrt__name__(tfunc(tcls(s2/sys/lib/python2.7/site-packages/hgext/factotum.pyt decoratorSs((R R!((R s2/sys/lib/python2.7/site-packages/hgext/factotum.pytmonkeypatch_methodRsc
Cs6tjj|||�\}}|rD|rD|j||�||fSd}tj|j||�}|r�|\}}|jd�}|jd�|jd�}}n|s�|r|s�d}ndt|f} |r�| |f} nt |t
| �\}}n|j||||�|j||�||fS(Nttprefixtusernametpasswordt*sservice=%s prefix=%ss
%s user=%s(turllib2tHTTPPasswordMgrWithDefaultRealmtfind_user_passwordt_writedebugRtreadauthforuriRtgett_serviceRRtadd_password(
R
trealmtauthuritusertpasswdR$tresRtauthR((s2/sys/lib/python2.7/site-packages/hgext/factotum.pyR*Xs*
" cCsC|jddd�a|jddd�a|jddd�adS(Ntfactotumt
executables/bin/auth/factotumt
mountpoints
/mnt/factotumtservicethg(tconfigR RR.(R((s2/sys/lib/python2.7/site-packages/hgext/factotum.pytuisetuprs(t__doc__tmercurial.i18nRt
mercurial.urlRt mercurialRRRR(RRRR"R*R<(((s2/sys/lib/python2.7/site-packages/hgext/factotum.pyt<module>.s
|