From 7affc2f7dec48dc886e9838b102bdd42d06b1d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sun, 11 Aug 2013 23:30:47 +0200 Subject: Include username in each credential type Key-based authentication also needs an username, so include it in each one. Also stop assuming a default username of "git" in the ssh transport which has no business making such a decision. --- include/git2/transport.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/git2/transport.h b/include/git2/transport.h index 1cc200eb4..e61b10423 100644 --- a/include/git2/transport.h +++ b/include/git2/transport.h @@ -59,6 +59,7 @@ typedef int (*git_cred_sign_callback)(void *, ...); /* A ssh key file and passphrase */ typedef struct git_cred_ssh_keyfile_passphrase { git_cred parent; + char *username; char *publickey; char *privatekey; char *passphrase; @@ -67,12 +68,21 @@ typedef struct git_cred_ssh_keyfile_passphrase { /* A ssh public key and authentication callback */ typedef struct git_cred_ssh_publickey { git_cred parent; + char *username; char *publickey; - size_t publickey_len; + size_t publickey_len; void *sign_callback; void *sign_data; } git_cred_ssh_publickey; +/** + * Check whether a credential object contains username information. + * + * @param cred object to check + * @return 1 if the credential object has non-NULL username, 0 otherwise + */ +GIT_EXTERN(int) git_cred_has_username(git_cred *cred); + /** * Creates a new plain-text username and password credential object. * The supplied credential parameter will be internally duplicated. @@ -92,6 +102,7 @@ GIT_EXTERN(int) git_cred_userpass_plaintext_new( * The supplied credential parameter will be internally duplicated. * * @param out The newly created credential object. + * @param username username to use to authenticate * @param publickey The path to the public key of the credential. * @param privatekey The path to the private key of the credential. * @param passphrase The passphrase of the credential. @@ -99,6 +110,7 @@ GIT_EXTERN(int) git_cred_userpass_plaintext_new( */ GIT_EXTERN(int) git_cred_ssh_keyfile_passphrase_new( git_cred **out, + const char *username, const char *publickey, const char *privatekey, const char *passphrase); @@ -108,6 +120,7 @@ GIT_EXTERN(int) git_cred_ssh_keyfile_passphrase_new( * The supplied credential parameter will be internally duplicated. * * @param out The newly created credential object. + * @param username username to use to authenticate * @param publickey The bytes of the public key. * @param publickey_len The length of the public key in bytes. * @param sign_fn The callback method for authenticating. @@ -116,6 +129,7 @@ GIT_EXTERN(int) git_cred_ssh_keyfile_passphrase_new( */ GIT_EXTERN(int) git_cred_ssh_publickey_new( git_cred **out, + const char *username, const char *publickey, size_t publickey_len, git_cred_sign_callback sign_fn, -- cgit v1.2.1