Exemplo n.º 1
0
Arquivo: ui.py Projeto: rdr78/rbuild
 def promptPassword(self, keyDesc, prompt, promptDesc, validateCallback):
     passwd = keystore.getPassword(keyDesc)
     if passwd:
         if validateCallback(passwd):
             return passwd
         else:
             # Invalidate the cached password (if Conary is new enough to
             # support that)
             try:
                 keystore.invalidatePassword(keyDesc)
             except AttributeError:
                 pass
     for x in range(3):
         self.write(promptDesc)
         try:
             passwd = self.inputPassword(prompt)
         except EOFError:
             break
         if not passwd:
             # User wants out but getpass eats Ctrl-C
             break
         if validateCallback(passwd):
             keystore.setPassword(keyDesc, passwd)
             return passwd
         self.write("The specified credentials were not valid.\n")
     return None
Exemplo n.º 2
0
def getPassword(server, userName=None, useCached=True):
    if userName is None:
        return None, None
    keyDesc = 'conary:%s:%s' % (server, userName)
    if useCached:
        passwd = keystore.getPassword(keyDesc)
        if passwd:
            return userName, passwd
    s = "Enter the password for %s on %s:" % (userName, server)
    passwd = getpass.getpass(s)
    if passwd and useCached:
        keystore.setPassword(keyDesc, passwd)
    return userName, passwd
Exemplo n.º 3
0
def getPassword(server, userName=None, useCached=True):
    if userName is None:
        return None, None
    keyDesc = 'conary:%s:%s' % (server, userName)
    if useCached:
        passwd = keystore.getPassword(keyDesc)
        if passwd:
            return userName, passwd
    s = "Enter the password for %s on %s:" % (userName, server)
    passwd = getpass.getpass(s)
    if passwd and useCached:
        keystore.setPassword(keyDesc, passwd)
    return userName, passwd
Exemplo n.º 4
0
 def _promptPassword(self, cfg):
     # Try to share descriptor with rbuild so only one prompt is seen
     user = cfg.rmakeUser[0]
     url = cfg.rmakeUrl.replace(':9999', '')
     keyDesc = 'rbuild:user:%s:%s' % (user, url)
     passwd = keystore.getPassword(keyDesc)
     if passwd and self._setAndCheckPassword(cfg, passwd):
         return
     for x in range(3):
         print "Please enter the password for user %r on %s" % (user,
                 cfg.rmakeUrl)
         passwd = getpass.getpass("Password: "******"The specified credentials were not valid."
         print
     raise errors.RmakeError("Could not authenticate to remote rMake server")