ssh-keyscan for ssh2 (was Re: openssh-2.9p1)
Wayne Davison
wayne at blorf.net
Sat May 19 07:00:02 EST 2001
On Fri, 18 May 2001 mouring at etoh.eviladmin.org wrote:
> Hmm.. not fully right.. <sigh> -DR does not work.
Yeah, I was about to mention that. Here's my fix. Note that the
c_keytypes value can have all bits on (7), and we grab the keys in order
of bits 1, 2, then 4.
..wayne..
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: ssh-keyscan.c
--- old/ssh-keyscan.c Fri May 18 13:48:58 2001
+++ ./ssh-keyscan.c Fri May 18 13:55:34 2001
@@ -319,16 +319,14 @@
}
Key *
-keygrab_ssh2(con *c, int keytypes)
+keygrab_ssh2(con *c)
{
Key *key;
packet_set_connection(c->c_fd, c->c_fd);
packet_set_ssh2_format();
- myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "ssh-rsa";
- if (keytypes == 2)
- myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "ssh-dss";
-
+ myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = c->c_keytypes & 2?
+ "ssh-dss": "ssh-rsa";
c->c_kex = kex_setup(myproposal);
c->c_kex->check_host_key = hostjump;
@@ -500,7 +498,7 @@
}
*cp = '\0';
fprintf(stderr, "# %s %s\n", c->c_name, buf);
- if (c->c_keytypes == 2 || c->c_keytypes == 4) {
+ if (!(c->c_keytypes & 1)) {
char remote_version[sizeof buf];
if (sscanf(buf, "SSH-%*d.%*d-%[^\n]\n", remote_version) == 1)
@@ -516,9 +514,16 @@
confree(s);
return;
}
- if (c->c_keytypes == 2 || c->c_keytypes == 4) {
- keyprint(c, keygrab_ssh2(c,c->c_keytypes));
- confree(s);
+ if (!(c->c_keytypes & 1)) {
+ keyprint(c, keygrab_ssh2(c));
+ if (c->c_keytypes & 2)
+ c->c_keytypes &= ~2;
+ else
+ c->c_keytypes &= ~4;
+ if (c->c_keytypes)
+ conrecycle(s, 1);
+ else
+ confree(s);
return;
}
c->c_status = CS_SIZE;
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
More information about the openssh-unix-dev
mailing list