version 1.47, 2004/03/08 09:38:05 |
version 1.47.2.2, 2005/03/10 17:15:05 |
|
|
#include "log.h" |
#include "log.h" |
#include "atomicio.h" |
#include "atomicio.h" |
#include "misc.h" |
#include "misc.h" |
|
#include "hostfile.h" |
|
|
/* Flag indicating whether IPv4 or IPv6. This can be set on the command line. |
/* Flag indicating whether IPv4 or IPv6. This can be set on the command line. |
Default value is AF_UNSPEC means both IPv4 and IPv6. */ |
Default value is AF_UNSPEC means both IPv4 and IPv6. */ |
|
|
|
|
int get_keytypes = KT_RSA1; /* Get only RSA1 keys by default */ |
int get_keytypes = KT_RSA1; /* Get only RSA1 keys by default */ |
|
|
|
int hash_hosts = 0; /* Hash hostname on output */ |
|
|
#define MAXMAXFD 256 |
#define MAXMAXFD 256 |
|
|
/* The number of seconds after which to give up on a TCP connection */ |
/* The number of seconds after which to give up on a TCP connection */ |
|
|
"ssh-dss": "ssh-rsa"; |
"ssh-dss": "ssh-rsa"; |
c->c_kex = kex_setup(myproposal); |
c->c_kex = kex_setup(myproposal); |
c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client; |
c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client; |
|
c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client; |
c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; |
c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; |
c->c_kex->verify_host_key = hostjump; |
c->c_kex->verify_host_key = hostjump; |
|
|
|
|
static void |
static void |
keyprint(con *c, Key *key) |
keyprint(con *c, Key *key) |
{ |
{ |
|
char *host = c->c_output_name ? c->c_output_name : c->c_name; |
|
|
if (!key) |
if (!key) |
return; |
return; |
|
if (hash_hosts && (host = host_hash(host, NULL, 0)) == NULL) |
|
fatal("host_hash failed"); |
|
|
fprintf(stdout, "%s ", c->c_output_name ? c->c_output_name : c->c_name); |
fprintf(stdout, "%s ", host); |
key_write(key, stdout); |
key_write(key, stdout); |
fputs("\n", stdout); |
fputs("\n", stdout); |
} |
} |
|
|
error("socket: %s", strerror(errno)); |
error("socket: %s", strerror(errno)); |
continue; |
continue; |
} |
} |
if (fcntl(s, F_SETFL, O_NONBLOCK) < 0) |
if (set_nonblock(s) == -1) |
fatal("F_SETFL: %s", strerror(errno)); |
fatal("%s: set_nonblock(%d)", __func__, s); |
if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0 && |
if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0 && |
errno != EINPROGRESS) |
errno != EINPROGRESS) |
error("connect (`%s'): %s", host, strerror(errno)); |
error("connect (`%s'): %s", host, strerror(errno)); |
|
|
|
|
bufsiz = sizeof(buf); |
bufsiz = sizeof(buf); |
cp = buf; |
cp = buf; |
while (bufsiz-- && (n = read(s, cp, 1)) == 1 && *cp != '\n') { |
while (bufsiz-- && (n = atomicio(read, s, cp, 1)) == 1 && *cp != '\n') { |
if (*cp == '\r') |
if (*cp == '\r') |
*cp = '\n'; |
*cp = '\n'; |
cp++; |
cp++; |
|
|
congreet(s); |
congreet(s); |
return; |
return; |
} |
} |
n = read(s, c->c_data + c->c_off, c->c_len - c->c_off); |
n = atomicio(read, s, c->c_data + c->c_off, c->c_len - c->c_off); |
if (n < 0) { |
if (n < 0) { |
error("read (%s): %s", c->c_name, strerror(errno)); |
error("read (%s): %s", c->c_name, strerror(errno)); |
confree(s); |
confree(s); |
|
|
static void |
static void |
usage(void) |
usage(void) |
{ |
{ |
fprintf(stderr, "usage: %s [-v46] [-p port] [-T timeout] [-t type] [-f file]\n" |
fprintf(stderr, "usage: %s [-46Hv] [-f file] [-p port] [-T timeout] [-t type]\n" |
"\t\t [host | addrlist namelist] [...]\n", |
"\t\t [host | addrlist namelist] [...]\n", |
__progname); |
__progname); |
exit(1); |
exit(1); |
|
|
if (argc <= 1) |
if (argc <= 1) |
usage(); |
usage(); |
|
|
while ((opt = getopt(argc, argv, "v46p:T:t:f:")) != -1) { |
while ((opt = getopt(argc, argv, "Hv46p:T:t:f:")) != -1) { |
switch (opt) { |
switch (opt) { |
|
case 'H': |
|
hash_hosts = 1; |
|
break; |
case 'p': |
case 'p': |
ssh_port = a2port(optarg); |
ssh_port = a2port(optarg); |
if (ssh_port == 0) { |
if (ssh_port == 0) { |