~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/ssh.py

  • Committer: Vincent Ladeuil
  • Date: 2007-10-22 15:18:24 UTC
  • mto: (2961.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2962.
  • Revision ID: v.ladeuil+lp@free.fr-20071022151824-eol757lk393ofc38
AuthenticationConfig can be queried for logins too (first step).

* bzrlib/transport/ssh.py:
(_paramiko_auth): Try to get a user from AuthenticationConfig.

* bzrlib/smtp_connection.py:
(SMTPConnection._authenticate): Try to get a user from
AuthenticationConfig.

* bzrlib/transport/ftp.py:
(FtpTransport._create_connection): Try to get a user from
AuthenticationConfig. Credentials are now (user, password) instead
of just password.

* bzrlib/tests/test_ftp_transport.py:
(TestFTPServerUI._add_authorized_user): Cleanup by refactoring.

* bzrlib/config.py:
(AuthenticationConfig.get_user): New method to get logins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
461
461
    # the username might be specified in ~/.ssh/config and we don't want to
462
462
    # force it to something else
463
463
    # Also, it would mess up the self.relpath() functionality
464
 
    username = username or getpass.getuser()
 
464
    auth = config.AuthenticationConfig()
 
465
    if username is None:
 
466
        username = auth.get_user('ssh', host, port=port)
 
467
        if username is None:
 
468
            # Default to local user
 
469
            username = getpass.getuser()
465
470
 
466
471
    if _use_ssh_agent:
467
472
        agent = paramiko.Agent()
487
492
            pass
488
493
 
489
494
    # give up and ask for a password
490
 
    auth = config.AuthenticationConfig()
491
495
    password = auth.get_password('ssh', host, username, port=port)
492
496
    try:
493
497
        paramiko_transport.auth_password(username, password)