diff options
Diffstat (limited to 'src/transports/cred.c')
| -rw-r--r-- | src/transports/cred.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/transports/cred.c b/src/transports/cred.c index 460ed04a2..528d6af73 100644 --- a/src/transports/cred.c +++ b/src/transports/cred.c @@ -87,6 +87,16 @@ static void ssh_key_free(struct git_cred *cred) git__free(c); } +static void ssh_interactive_free(struct git_cred *cred) +{ + git_cred_ssh_interactive *c = (git_cred_ssh_interactive *)cred; + + git__free(c->username); + + git__memzero(c, sizeof(*c)); + git__free(c); +} + static void ssh_custom_free(struct git_cred *cred) { git_cred_ssh_custom *c = (git_cred_ssh_custom *)cred; @@ -142,6 +152,32 @@ int git_cred_ssh_key_new( return 0; } +int git_cred_ssh_interactive_new( + git_cred **out, + const char *username, + git_cred_ssh_interactive_callback prompt_callback, + void *payload) +{ + git_cred_ssh_interactive *c; + + assert(out && username && prompt_callback); + + c = git__calloc(1, sizeof(git_cred_ssh_interactive)); + GITERR_CHECK_ALLOC(c); + + c->parent.credtype = GIT_CREDTYPE_SSH_INTERACTIVE; + c->parent.free = ssh_interactive_free; + + c->username = git__strdup(username); + GITERR_CHECK_ALLOC(c->username); + + c->prompt_callback = prompt_callback; + c->payload = payload; + + *out = &c->parent; + return 0; +} + int git_cred_ssh_key_from_agent(git_cred **cred, const char *username) { git_cred_ssh_key *c; |
