o ö]Lb{ã@sàdZddlmZddlZddlmZddlmZddlm Z ddl m Z m Z m Z mZmZejZejZdZdaaaiZe  e¡Zed d d d ed d dd ed ddd dd„Zdd„Zdd„Zeeƒdd„ƒZdd„ZdS)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= 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)ÚerrorÚhttpconnectionÚ registrarÚurlÚutilé€ófactotumó executables/bin/auth/factotum)Údefaultó mountpoints /mnt/factotumóserviceshgcCsL|j ¡s t tdƒ¡‚d|vrd|}d|}t t dt |f¡¡dS)Nsfactotum not interactivesuser=s%s user?s %s !password?s %s -g '%s') ÚuiÚ interactiverÚAbortrÚosÚsystemrÚ tonativestrÚ _executable)ÚselfÚparams©rú0/usr/lib/python3/dist-packages/hgext/factotum.pyÚ auth_getkeyYs rc Csd|} t dttj¡}znzVt |d|¡t |t¡ ¡}|ddkrdt |d¡t |t¡ dd¡\}}}|dkrd| d ¡rY|  d ¡rR|d d …  d d ¡}nt   t d ƒ¡‚||fWWt |¡SWnttfyut   t dƒ¡‚wWt |¡nt |¡w|||ƒq)Ns proto=pass %sTs%s/rpcsstart %srsoksreadéó'ééÿÿÿÿs''smalformed password stringsfactotum not responding)rÚopenÚ _mountpointÚO_RDWRÚwriteÚreadÚERRMAXÚsplitÚ startswithÚendswithÚreplacerrrÚcloseÚOSErrorÚIOError)rÚgetkeyrÚfdÚlÚstatusÚuserÚpasswdrrrÚauth_getuserpasswdbs0      €ýÿ€ ír4cs‡fdd„}|S)Ncstˆ|j|ƒ|S)N)rÚ__name__)Úfunc©ÚclsrrÚ decorator{sz%monkeypatch_method..decoratorr)r8r9rr7rÚmonkeypatch_methodzs r:c CsÜ|j ||¡\}}|r|r| ||¡||fSd}t |j||¡}|r7|\}}| d¡}| d¡| d¡}}|r;|s\|sF| d¡d ¡}dt |f} |rTd| |f} t |t | ƒ\}}|  ||||¡| ||¡||fS) Nósprefixsusernamespasswordó rsservice=%s prefix=%ss %s user=%s) ÚpasswddbÚfind_user_passwordÚ _writedebugrÚreadauthforurirÚgetr'ÚlowerÚ_servicer4rÚ add_password) rÚrealmÚauthurir2r3ÚprefixÚresrÚauthrrrrr>‚s(     r>cCs(| dd¡a| dd¡a| dd¡adS)Nr r rr)Úconfigrr"rC)rrrrÚuisetupœs  rK)Ú__doc__Ú __future__rrÚmercurial.i18nrÚmercurial.pycompatrÚmercurial.utilsrÚ mercurialrrrr r ÚurlreqÚ passwordmgrr&rr"rCÚ configtableÚ configitemrr4r:r>rKrrrrÚsD      ýýý