1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Pageant client: tolerate failure to list keys.

This enables Pageant to act as a client for OpenSSH's agent, which
nowadays refuses to respond to SSH1_AGENTC_REQUEST_RSA_IDENTITIES, or
any other SSH1_AGENTC_* message. It now treats SSH_AGENT_FAILURE in
response to either 'list identities' request the same as successfully
receiving an empty list.
This commit is contained in:
Simon Tatham 2020-03-03 21:44:19 +00:00
parent e85b159d87
commit cdffb995df

View File

@ -2082,64 +2082,61 @@ int pageant_enum_keys(pageant_key_enum_fn_t callback, void *callback_ctx,
int toret = PAGEANT_ACTION_FAILURE; int toret = PAGEANT_ACTION_FAILURE;
kl1 = pageant_get_keylist(1); kl1 = pageant_get_keylist(1);
if (!kl1) { if (kl1 && kl1->broken) {
*retstr = dupstr("Did not receive an SSH-1 key list from agent");
goto out;
}
if (kl1->broken) {
*retstr = dupstr("Received broken SSH-1 key list from agent"); *retstr = dupstr("Received broken SSH-1 key list from agent");
goto out; goto out;
} }
kl2 = pageant_get_keylist(2); kl2 = pageant_get_keylist(2);
if (!kl2) { if (kl2 && kl2->broken) {
*retstr = dupstr("Did not receive an SSH-2 key list from agent");
goto out;
}
if (kl2->broken) {
*retstr = dupstr("Received broken SSH-2 key list from agent"); *retstr = dupstr("Received broken SSH-2 key list from agent");
goto out; goto out;
} }
for (size_t i = 0; i < kl1->nkeys; i++) { if (kl1) {
cbkey.blob = strbuf_new(); for (size_t i = 0; i < kl1->nkeys; i++) {
put_datapl(cbkey.blob, kl1->keys[i].blob); cbkey.blob = strbuf_new();
cbkey.comment = mkstr(kl1->keys[i].comment); put_datapl(cbkey.blob, kl1->keys[i].blob);
cbkey.ssh_version = 1; cbkey.comment = mkstr(kl1->keys[i].comment);
cbkey.ssh_version = 1;
/* Decode public blob into a key in order to fingerprint it */ /* Decode public blob into a key in order to fingerprint it */
RSAKey rkey; RSAKey rkey;
memset(&rkey, 0, sizeof(rkey)); memset(&rkey, 0, sizeof(rkey));
{ {
BinarySource src[1]; BinarySource src[1];
BinarySource_BARE_INIT_PL(src, kl1->keys[i].blob); BinarySource_BARE_INIT_PL(src, kl1->keys[i].blob);
get_rsa_ssh1_pub(src, &rkey, RSA_SSH1_EXPONENT_FIRST); get_rsa_ssh1_pub(src, &rkey, RSA_SSH1_EXPONENT_FIRST);
if (get_err(src)) { if (get_err(src)) {
*retstr = dupstr("Received an invalid SSH-1 key from agent"); *retstr = dupstr(
goto out; "Received an invalid SSH-1 key from agent");
goto out;
}
} }
} char *fingerprint = rsa_ssh1_fingerprint(&rkey);
char *fingerprint = rsa_ssh1_fingerprint(&rkey); freersakey(&rkey);
freersakey(&rkey);
callback(callback_ctx, fingerprint, cbkey.comment, &cbkey); callback(callback_ctx, fingerprint, cbkey.comment, &cbkey);
strbuf_free(cbkey.blob); strbuf_free(cbkey.blob);
sfree(cbkey.comment); sfree(cbkey.comment);
sfree(fingerprint); sfree(fingerprint);
}
} }
for (size_t i = 0; i < kl2->nkeys; i++) { if (kl2) {
cbkey.blob = strbuf_new(); for (size_t i = 0; i < kl2->nkeys; i++) {
put_datapl(cbkey.blob, kl2->keys[i].blob); cbkey.blob = strbuf_new();
cbkey.comment = mkstr(kl2->keys[i].comment); put_datapl(cbkey.blob, kl2->keys[i].blob);
cbkey.ssh_version = 2; cbkey.comment = mkstr(kl2->keys[i].comment);
cbkey.ssh_version = 2;
char *fingerprint = ssh2_fingerprint_blob(kl2->keys[i].blob); char *fingerprint = ssh2_fingerprint_blob(kl2->keys[i].blob);
callback(callback_ctx, fingerprint, cbkey.comment, &cbkey); callback(callback_ctx, fingerprint, cbkey.comment, &cbkey);
sfree(fingerprint); sfree(fingerprint);
sfree(cbkey.comment); sfree(cbkey.comment);
strbuf_free(cbkey.blob); strbuf_free(cbkey.blob);
}
} }
*retstr = NULL; *retstr = NULL;