Beispiel #1
0
 def passwd(self, argv):
     """passwd [-a <authservice> | -l | -s ] <username>
 Change the password for the given user. Also change the authorization method."""
     opts, longopts, args = self.getopt(argv, "a:sl")
     for opt, arg in opts:
         if opt == "-a":
             longopts["authservice"] = arg
         elif opt == "-l":
             longopts["authservice"] = "local"
         elif opt == "-s":
             longopts["authservice"] = "system"
     username = args[0]
     user = _session.query(models.User).filter(models.User.username==username).one()
     tries = 0
     while tries < 3:
         newpass = tty.getpass("New password for %s: " % (user,))
         newpass2 = tty.getpass("New password again: ")
         if newpass == newpass2:
             break
         tries += 1
     else:
         self._print("Password not updated.")
         return
     if newpass:
         user.password = newpass
         models.update(user, **longopts)
         _session.commit()
     else:
         self._print("No password, not updated.")
Beispiel #2
0
def get_pass(verify):
    """Basic callback for getting passphrase."""
    if verify:
        retries = 3
        while retries > 0:
            pw = tty.getpass("Passphrase? ")
            npw = tty.getpass("Passphrase again? ")
            if pw == npw:
                return pw
            print("Phrases don't match. Please try again.")
            retries -= 1
        raise crypto.Error("Too many tries reading passphrase.")
    else:
        return tty.getpass("Passphrase? ")
Beispiel #3
0
def get_pass(verify):
    """Basic callback for getting passphrase."""
    if verify:
        retries = 3
        while retries > 0:
            pw = tty.getpass("Passphrase? ")
            npw = tty.getpass("Passphrase again? ")
            if pw == npw:
                return pw
            print("Phrases don't match. Please try again.")
            retries -= 1
        raise crypto.Error("Too many tries reading passphrase.")
    else:
        return tty.getpass("Passphrase? ")
Beispiel #4
0
def submit(crontab, username=None, password=None):
    """Submit a crontab via the crontab program.
    Supply a crontab object. If it is to be installed for a different user
    supply the `username` parameter. If this is not run as root, then sudo is
    used and you must supply your own password for sudo."""
    if username is None:
        ct = proctools.spawnpipe("crontab -")
        ct.write(str(crontab))
        ct.close()
        return ct.wait()
    else:
        if os.getuid() == 0:
            ct = proctools.spawnpipe("crontab -u %s -" % (username, ))
            ct.write(str(crontab))
            ct.close()
            return ct.wait()
        else:
            from pycopia import sudo
            if password is None:
                from pycopia import tty
                password = tty.getpass("Your password:"******"crontab -u %s -" % (username, ), password=password)
            ct.write(str(crontab))
            ct.close()
            return ct.wait()
Beispiel #5
0
def submit(crontab, username=None, password=None):
    """Submit a crontab via the crontab program. 
    Supply a crontab object. If it is to be installed for a different user
    supply the `username` parameter. If this is not run as root, then sudo is
    used and you must supply your own password for sudo."""
    if username is None:
        ct = proctools.spawnpipe("crontab -")
        ct.write(str(crontab))
        ct.close()
        return ct.wait()
    else:
        if os.getuid() == 0:
            ct = proctools.spawnpipe("crontab -u %s -" % (username,))
            ct.write(str(crontab))
            ct.close()
            return ct.wait()
        else:
            from pycopia import sudo
            if password is None:
                from pycopia import tty
                password = tty.getpass("Your password:"******"crontab -u %s -" % (username,), password=password)
            ct.write(str(crontab))
            ct.close()
            return ct.wait()
Beispiel #6
0
 def login_cram_md5(self, argv):
     """login_cram_md5 [<user>]
 Force logging in using CRAM_MD5."""
     if len(argv) > 1:
         USER = argv[1]
     else:
         USER = tty.getuser()
     PASS = tty.getpass()
     self._print_msg(self._client.login_cram_md5(USER, PASS))
Beispiel #7
0
 def login(self, argv):
     """login [<username>]
 Identify client using plaintext password."""
     if len(argv) > 1:
         USER = argv[1]
     else:
         USER = tty.getuser()
     PASS = tty.getpass()
     self._print_msg(self._client.login(USER, PASS))
Beispiel #8
0
 def login_cram_md5(self, argv):
     """login_cram_md5 [<user>]
 Force logging in using CRAM_MD5."""
     if len(argv) > 1:
         USER = argv[1]
     else:
         USER = tty.getuser()
     PASS = tty.getpass()
     self._print_msg(self._client.login_cram_md5(USER, PASS))
Beispiel #9
0
 def login(self, argv):
     """login [<username>]
 Identify client using plaintext password."""
     if len(argv) > 1:
         USER = argv[1]
     else:
         USER = tty.getuser()
     PASS = tty.getpass()
     self._print_msg(self._client.login(USER, PASS))
Beispiel #10
0
 def login(self, argv):
     """login <user> [<password>]
 Perform an authentication protocol with the given name and password.
 Perform this after `ehlo`."""
     user = argv[1]
     if len(argv) > 2:
         passwd = argv[2]
     else:
         passwd = tty.getpass("AUTH password: ")
     self._print_msg(self._client.login(user, passwd))
Beispiel #11
0
 def login(self, argv):
     """login <user> [<password>]
 Perform an authentication protocol with the given name and password.
 Perform this after `ehlo`."""
     user = argv[1]
     if len(argv) > 2:
         passwd = argv[2]
     else:
         passwd = tty.getpass("AUTH password: ")
     self._print_msg(self._client.login(user, passwd))
Beispiel #12
0
 def get_password(self, prompt="Password: "):
     return tty.getpass(prompt)
Beispiel #13
0
def ask_password():
    password = tty.getpass("Password? ")
    password2 = tty.getpass("Again: ")
    if password != password2:
        return None
    return password
Beispiel #14
0
 def get_password(self, prompt="Password: "):
     return tty.getpass(prompt)