summaryrefslogtreecommitdiff
path: root/src/transports/ssh.c
diff options
context:
space:
mode:
authorJacques Germishuys <jacquesg@striata.com>2014-04-17 23:03:44 +0200
committerJacques Germishuys <jacquesg@striata.com>2014-04-18 17:58:25 +0200
commit478408c01006f39ab916675bc84b8a7340bae086 (patch)
tree48bc3acd3a69ad8b4144d31b7c8ea1efd5472e5a /src/transports/ssh.c
parent3c69bebc1c18444e9358c33f56c7cfefea4d1a8f (diff)
downloadlibgit2-478408c01006f39ab916675bc84b8a7340bae086.tar.gz
Introduce git_cred_ssh_interactive_new()
This allows for keyboard-interactive based SSH authentication
Diffstat (limited to 'src/transports/ssh.c')
-rw-r--r--src/transports/ssh.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 879af9059..48e51f2ae 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -313,6 +313,27 @@ static int _git_ssh_authenticate_session(
c->publickey_len, c->sign_callback, &c->sign_data);
break;
}
+ case GIT_CREDTYPE_SSH_INTERACTIVE: {
+ void **abstract = libssh2_session_abstract(session);
+ git_cred_ssh_interactive *c = (git_cred_ssh_interactive *)cred;
+
+ /* ideally, we should be able to set this by calling
+ * libssh2_session_init_ex() instead of libssh2_session_init().
+ * libssh2's API is inconsistent here i.e. libssh2_userauth_publickey()
+ * allows you to pass the `abstract` as part of the call, whereas
+ * libssh2_userauth_keyboard_interactive() does not!
+ *
+ * The only way to set the `abstract` pointer is by calling
+ * libssh2_session_abstract(), which will replace the existing
+ * pointer as is done below. This is safe for now (at time of writing),
+ * but may not be valid in future.
+ */
+ *abstract = c->payload;
+
+ rc = libssh2_userauth_keyboard_interactive(
+ session, c->username, c->prompt_callback);
+ break;
+ }
default:
rc = LIBSSH2_ERROR_AUTHENTICATION_FAILED;
}
@@ -397,6 +418,7 @@ static int _git_ssh_setup_conn(
&t->cred, t->owner->url, user,
GIT_CREDTYPE_USERPASS_PLAINTEXT |
GIT_CREDTYPE_SSH_KEY |
+ GIT_CREDTYPE_SSH_INTERACTIVE |
GIT_CREDTYPE_SSH_CUSTOM,
t->owner->cred_acquire_payload) < 0)
goto on_error;