MCPcopy Index your code
hub / github.com/git/git / get_ssh_key_fingerprint

Function get_ssh_key_fingerprint

gpg-interface.c:828–869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

826}
827
828static char *get_ssh_key_fingerprint(const char *signing_key)
829{
830 struct child_process ssh_keygen = CHILD_PROCESS_INIT;
831 int ret = -1;
832 struct strbuf fingerprint_stdout = STRBUF_INIT;
833 char *fingerprint_ret, *begin, *delim;
834 const char *literal_key = NULL;
835
836 /*
837 * With SSH Signing this can contain a filename or a public key
838 * For textual representation we usually want a fingerprint
839 */
840 if (is_literal_ssh_key(signing_key, &literal_key)) {
841 strvec_pushl(&ssh_keygen.args, "ssh-keygen", "-lf", "-", NULL);
842 ret = pipe_command(&ssh_keygen, literal_key,
843 strlen(literal_key), &fingerprint_stdout, 0,
844 NULL, 0);
845 } else {
846 strvec_pushl(&ssh_keygen.args, "ssh-keygen", "-lf",
847 configured_signing_key, NULL);
848 ret = pipe_command(&ssh_keygen, NULL, 0, &fingerprint_stdout, 0,
849 NULL, 0);
850 }
851
852 if (!!ret)
853 die_errno(_("failed to get the ssh fingerprint for key '%s'"),
854 signing_key);
855
856 begin = fingerprint_stdout.buf;
857 delim = strchr(begin, ' ');
858 if (!delim)
859 die(_("failed to get the ssh fingerprint for key %s"),
860 signing_key);
861 begin = delim + 1;
862 delim = strchr(begin, ' ');
863 if (!delim)
864 die(_("failed to get the ssh fingerprint for key %s"),
865 signing_key);
866 fingerprint_ret = xmemdupz(begin, delim - begin);
867 strbuf_release(&fingerprint_stdout);
868 return fingerprint_ret;
869}
870
871/* Returns the first public key from an ssh-agent to use for signing */
872static char *get_default_ssh_signing_key(void)

Callers 1

get_ssh_key_idFunction · 0.85

Calls 7

is_literal_ssh_keyFunction · 0.85
strvec_pushlFunction · 0.85
pipe_commandFunction · 0.85
die_errnoFunction · 0.85
xmemdupzFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected