hgext/factotum.py
changeset 25078 e8348f1cc228
parent 23393 c834c0194dbb
child 26587 56b2bcea2529
equal deleted inserted replaced
25077:68633ff2b608 25078:e8348f1cc228
    65 def auth_getuserpasswd(self, getkey, params):
    65 def auth_getuserpasswd(self, getkey, params):
    66     params = 'proto=pass %s' % params
    66     params = 'proto=pass %s' % params
    67     while True:
    67     while True:
    68         fd = os.open('%s/rpc' % _mountpoint, os.O_RDWR)
    68         fd = os.open('%s/rpc' % _mountpoint, os.O_RDWR)
    69         try:
    69         try:
    70             try:
    70             os.write(fd, 'start %s' % params)
    71                 os.write(fd, 'start %s' % params)
    71             l = os.read(fd, ERRMAX).split()
    72                 l = os.read(fd, ERRMAX).split()
    72             if l[0] == 'ok':
    73                 if l[0] == 'ok':
    73                 os.write(fd, 'read')
    74                     os.write(fd, 'read')
    74                 status, user, passwd = os.read(fd, ERRMAX).split(None, 2)
    75                     status, user, passwd = os.read(fd, ERRMAX).split(None, 2)
    75                 if status == 'ok':
    76                     if status == 'ok':
    76                     if passwd.startswith("'"):
    77                         if passwd.startswith("'"):
    77                         if passwd.endswith("'"):
    78                             if passwd.endswith("'"):
    78                             passwd = passwd[1:-1].replace("''", "'")
    79                                 passwd = passwd[1:-1].replace("''", "'")
    79                         else:
    80                             else:
    80                             raise util.Abort(_('malformed password string'))
    81                                 raise util.Abort(_('malformed password string'))
    81                     return (user, passwd)
    82                         return (user, passwd)
    82         except (OSError, IOError):
    83             except (OSError, IOError):
    83             raise util.Abort(_('factotum not responding'))
    84                 raise util.Abort(_('factotum not responding'))
       
    85         finally:
    84         finally:
    86             os.close(fd)
    85             os.close(fd)
    87         getkey(self, params)
    86         getkey(self, params)
    88 
    87 
    89 def monkeypatch_method(cls):
    88 def monkeypatch_method(cls):