summaryrefslogtreecommitdiff
path: root/src/transports/cred_helpers.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-06-25 16:27:43 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-06-26 22:58:39 +0200
commitccb85c8fa146585e9e329ec7abfa00555b03dce2 (patch)
tree1a045d8379da9095eefefec683ffb2fb207629f2 /src/transports/cred_helpers.c
parentd1c281a5525882c4a6f157ea1f18837d5819dab3 (diff)
downloadlibgit2-ccb85c8fa146585e9e329ec7abfa00555b03dce2.tar.gz
ssh: make sure to ask for a username and use the same one
In order to know which authentication methods are supported/allowed by the ssh server, we need to send a NONE auth request, which needs a username associated with it. Most ssh server implementations do not allow switching the username between authentication attempts, which means we cannot use a dummy username and then switch. There are two ways around this. The first is to use a different connection, which an earlier commit implements, but this increases how long it takes to get set up, and without knowing the right username, we cannot guarantee that the list we get in response is the right one. The second is what's implemented here: if there is no username specified in the url, ask for it first. We can then ask for the list of auth methods and use the user's credentials in the same connection.
Diffstat (limited to 'src/transports/cred_helpers.c')
-rw-r--r--src/transports/cred_helpers.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/transports/cred_helpers.c b/src/transports/cred_helpers.c
index d420e3e3c..5cc9b0869 100644
--- a/src/transports/cred_helpers.c
+++ b/src/transports/cred_helpers.c
@@ -41,6 +41,9 @@ int git_cred_userpass(
else
return -1;
+ if (GIT_CREDTYPE_USERNAME & allowed_types)
+ return git_cred_username_new(cred, effective_username);
+
if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 ||
git_cred_userpass_plaintext_new(cred, effective_username, userpass->password) < 0)
return -1;