mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +08:00
c lib: Allow the ssh keys to be configured
This commit is contained in:
@ -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");
|
||||||
|
@ -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;
|
||||||
|
Reference in New Issue
Block a user