o ]Lb{@sdZddlmZddlZddlmZddlmZddlm Z ddl m Z m Z m Z mZmZejZejZdZdaaaiZe eZed d d d ed d dd ed ddd ddZddZddZeeddZddZdS)ahttp 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= user= !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. )absolute_importN)_)setattr)procutil)errorhttpconnection registrarurlutilfactotum executables/bin/auth/factotum)default mountpoints /mnt/factotumserviceshgcCsL|js ttdd|vrd|}d|}ttdt |fdS)Nsfactotum not interactivesuser=s%s user?s %s !password?s %s -g '%s') ui interactiverAbortrossystemr tonativestr _executable)selfparamsr0/usr/lib/python3/dist-packages/hgext/factotum.py auth_getkeyYs rc Csd|} tdttj}znzVt|d|t|t}|ddkrdt|dt|tdd\}}}|dkrd|d rY| d rR|d d  d d }nt t d ||fWWt|SWnttfyut t dwWt|nt|w|||q)Ns proto=pass %sTs%s/rpcsstart %srsoksread's''smalformed password stringsfactotum not responding)ropen _mountpointO_RDWRwritereadERRMAXsplit startswithendswithreplacerrrcloseOSErrorIOError)rgetkeyrfdlstatususerpasswdrrrauth_getuserpasswdbs0       r4csfdd}|S)Ncst|j||S)N)r__name__)funcclsrr decorator{sz%monkeypatch_method..decoratorr)r8r9rr7rmonkeypatch_methodzs r:c Cs|j||\}}|r|r|||||fSd}t|j||}|r7|\}}|d}|d|d}}|r;|s\|sF|dd}dt |f} |rTd| |f} t |t | \}}| |||||||||fS) Nsprefixsusernamespassword rsservice=%s prefix=%ss %s user=%s) passwddbfind_user_password _writedebugrreadauthforurirgetr'lower_servicer4r add_password) rrealmauthurir2r3prefixresrauthrrrrr>s(     r>cCs(|dda|dda|ddadS)Nr r rr)configrr"rC)rrrruisetups  rK)__doc__ __future__rrmercurial.i18nrmercurial.pycompatrmercurial.utilsr mercurialrrrr r urlreq passwordmgrr&rr"rC configtable configitemrr4r:r>rKrrrrsD