Commit babdc376c7a0ed698ada5f0512789bd99a8b2c4a

Carlos Martín Nieto 2015-06-04T13:02:59

Merge pull request #3172 from Therzok/patch-2 Change error when running out of ssh agent keys

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 58f1aeb..5c8545f 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -293,8 +293,14 @@ static int ssh_agent_auth(LIBSSH2_SESSION *session, git_cred_ssh_key *c) {
 		if (rc < 0)
 			goto shutdown;
 
-		if (rc == 1)
+		/* rc is set to 1 whenever the ssh agent ran out of keys to check.
+		 * Set the error code to authentication failure rather than erroring
+		 * out with an untranslatable error code.
+		 */
+		if (rc == 1) {
+			rc = LIBSSH2_ERROR_AUTHENTICATION_FAILED;
 			goto shutdown;
+		}
 
 		rc = libssh2_agent_userauth(agent, c->username, curr);