mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 09:41:04 +00:00
cred: introduce username-only cred
This exists as ssh needs to know about the username to use before it can query for the supported authentication methods.
This commit is contained in:
parent
d7f962f408
commit
54da69588e
@ -44,6 +44,14 @@ typedef enum {
|
|||||||
|
|
||||||
/* git_cred_ssh_interactive */
|
/* git_cred_ssh_interactive */
|
||||||
GIT_CREDTYPE_SSH_INTERACTIVE = (1u << 4),
|
GIT_CREDTYPE_SSH_INTERACTIVE = (1u << 4),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Username-only information
|
||||||
|
*
|
||||||
|
* If the SSH transport does not know which username to use,
|
||||||
|
* it will ask via this credential type.
|
||||||
|
*/
|
||||||
|
GIT_CREDTYPE_USERNAME = (1u << 5),
|
||||||
} git_credtype_t;
|
} git_credtype_t;
|
||||||
|
|
||||||
/* The base structure for all credential types */
|
/* The base structure for all credential types */
|
||||||
@ -105,6 +113,12 @@ typedef struct git_cred_ssh_custom {
|
|||||||
/** A key for NTLM/Kerberos "default" credentials */
|
/** A key for NTLM/Kerberos "default" credentials */
|
||||||
typedef struct git_cred git_cred_default;
|
typedef struct git_cred git_cred_default;
|
||||||
|
|
||||||
|
/** Username-only credential information */
|
||||||
|
typedef struct git_cred_username {
|
||||||
|
git_cred parent;
|
||||||
|
char username[1];
|
||||||
|
} git_cred_username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether a credential object contains username information.
|
* Check whether a credential object contains username information.
|
||||||
*
|
*
|
||||||
|
@ -129,6 +129,11 @@ static void default_free(struct git_cred *cred)
|
|||||||
git__free(c);
|
git__free(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void username_free(struct git_cred *cred)
|
||||||
|
{
|
||||||
|
git__free(cred);
|
||||||
|
}
|
||||||
|
|
||||||
int git_cred_ssh_key_new(
|
int git_cred_ssh_key_new(
|
||||||
git_cred **cred,
|
git_cred **cred,
|
||||||
const char *username,
|
const char *username,
|
||||||
@ -263,3 +268,21 @@ int git_cred_default_new(git_cred **cred)
|
|||||||
*cred = c;
|
*cred = c;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int git_cred_username_new(git_cred **cred, const char *username)
|
||||||
|
{
|
||||||
|
git_cred_username *c;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
assert(cred);
|
||||||
|
|
||||||
|
len = strlen(username);
|
||||||
|
c = git__malloc(sizeof(git_cred_username) + len + 1);
|
||||||
|
GITERR_CHECK_ALLOC(c);
|
||||||
|
|
||||||
|
c->parent.credtype = GIT_CREDTYPE_USERNAME;
|
||||||
|
c->parent.free = username_free;
|
||||||
|
memcpy(c->username, username, len + 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user