| 826 | } |
| 827 | |
| 828 | static 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 */ |
| 872 | static char *get_default_ssh_signing_key(void) |
no test coverage detected