c lib: Allow the ssh keys to be configured

This commit is contained in:
Vishesh Handa
2019-05-15 17:36:07 +02:00
parent b00a0ca04a
commit e8109a20e8
2 changed files with 15 additions and 5 deletions

View File

@ -273,6 +273,17 @@ int fetch_progress(const git_transfer_progress *stats, void *payload)
return 0; return 0;
} }
char *g_public_key_path = NULL;
char *g_private_key_path = NULL;
char *g_passcode = NULL;
void gj_set_ssh_keys_paths(char *public_key, char *private_key, char *passcode)
{
g_public_key_path = public_key;
g_private_key_path = private_key;
g_passcode = passcode;
}
int credentials_cb(git_cred **out, const char *url, const char *username_from_url, int credentials_cb(git_cred **out, const char *url, const char *username_from_url,
unsigned int allowed_types, void *payload) unsigned int allowed_types, void *payload)
{ {
@ -286,11 +297,8 @@ int credentials_cb(git_cred **out, const char *url, const char *username_from_ur
return -1; return -1;
} }
char *publickey = "/Users/vishesh/.ssh/id_rsa.pub"; int err = git_cred_ssh_key_new(out, username_from_url,
char *privatekey = "/Users/vishesh/.ssh/id_rsa"; g_public_key_path, g_private_key_path, g_passcode);
char *passphrase = "";
int err = git_cred_ssh_key_new(out, username_from_url, publickey, privatekey, passphrase);
if (err < 0) if (err < 0)
{ {
printf("Credentials CB Error"); printf("Credentials CB Error");

View File

@ -15,6 +15,8 @@ int gj_git_reset_hard(char *git_base_path, char *ref);
int gj_git_add(char *git_base_path, char *pattern); int gj_git_add(char *git_base_path, char *pattern);
int gj_git_rm(char *git_base_path, char *pattern); int gj_git_rm(char *git_base_path, char *pattern);
void gj_set_ssh_keys_paths(char *public_key, char *private_key, char *passcode);
typedef struct typedef struct
{ {
char *message; char *message;