Git-Raw
view release on metacpan or search on metacpan
deps/libgit2/src/libgit2/transports/credential.c view on Meta::CPAN
/* Zero the memory which previously held the publickey */
size_t key_len = strlen(c->publickey);
git__memzero(c->publickey, key_len);
git__free(c->publickey);
}
git__free(c);
}
static void default_free(struct git_credential *cred)
{
git_credential_default *c = (git_credential_default *)cred;
git__free(c);
}
static void username_free(struct git_credential *cred)
{
git__free(cred);
}
int git_credential_ssh_key_new(
git_credential **cred,
const char *username,
const char *publickey,
const char *privatekey,
const char *passphrase)
{
return git_credential_ssh_key_type_new(
cred,
username,
publickey,
privatekey,
passphrase,
GIT_CREDENTIAL_SSH_KEY);
}
int git_credential_ssh_key_memory_new(
git_credential **cred,
const char *username,
const char *publickey,
const char *privatekey,
const char *passphrase)
{
#ifdef GIT_SSH_MEMORY_CREDENTIALS
return git_credential_ssh_key_type_new(
cred,
username,
publickey,
privatekey,
passphrase,
GIT_CREDENTIAL_SSH_MEMORY);
#else
GIT_UNUSED(cred);
GIT_UNUSED(username);
GIT_UNUSED(publickey);
GIT_UNUSED(privatekey);
GIT_UNUSED(passphrase);
git_error_set(GIT_ERROR_INVALID,
"this version of libgit2 was not built with ssh memory credentials.");
return -1;
#endif
}
static int git_credential_ssh_key_type_new(
git_credential **cred,
const char *username,
const char *publickey,
const char *privatekey,
const char *passphrase,
git_credential_t credtype)
{
git_credential_ssh_key *c;
GIT_ASSERT_ARG(username);
GIT_ASSERT_ARG(cred);
GIT_ASSERT_ARG(privatekey);
c = git__calloc(1, sizeof(git_credential_ssh_key));
GIT_ERROR_CHECK_ALLOC(c);
c->parent.credtype = credtype;
c->parent.free = ssh_key_free;
c->username = git__strdup(username);
GIT_ERROR_CHECK_ALLOC(c->username);
c->privatekey = git__strdup(privatekey);
GIT_ERROR_CHECK_ALLOC(c->privatekey);
if (publickey) {
c->publickey = git__strdup(publickey);
GIT_ERROR_CHECK_ALLOC(c->publickey);
}
if (passphrase) {
c->passphrase = git__strdup(passphrase);
GIT_ERROR_CHECK_ALLOC(c->passphrase);
}
*cred = &c->parent;
return 0;
}
int git_credential_ssh_interactive_new(
git_credential **out,
const char *username,
git_credential_ssh_interactive_cb prompt_callback,
void *payload)
{
git_credential_ssh_interactive *c;
GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(username);
GIT_ASSERT_ARG(prompt_callback);
c = git__calloc(1, sizeof(git_credential_ssh_interactive));
GIT_ERROR_CHECK_ALLOC(c);
c->parent.credtype = GIT_CREDENTIAL_SSH_INTERACTIVE;
( run in 0.566 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )