*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-keyscan.c,v 1.27 2001/08/05 23:29:58 markus Exp $");
+RCSID("$OpenBSD: ssh-keyscan.c,v 1.30 2001/10/08 19:05:05 markus Exp $");
#if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H)
#include <sys/queue.h>
/* Flag indicating whether IPv4 or IPv6. This can be set on the command line.
Default value is AF_UNSPEC means both IPv4 and IPv6. */
-#ifdef IPV4_DEFAULT
-int IPv4or6 = AF_INET;
-#else
int IPv4or6 = AF_UNSPEC;
-#endif
int ssh_port = SSH_DEFAULT_PORT;
-
-#define KT_RSA1 1
-#define KT_DSA 2
-#define KT_RSA 4
-
-int get_keytypes = KT_RSA1; /* Get only RSA1 keys by default */
+
+#define KT_RSA1 1
+#define KT_DSA 2
+#define KT_RSA 4
+
+int get_keytypes = KT_RSA1; /* Get only RSA1 keys by default */
#define MAXMAXFD 256
int ncon;
int nonfatal_fatal = 0;
jmp_buf kexjmp;
+Key *kexjmp_key;
/*
* Keep a connection structure for each file descriptor. The state
static int
hostjump(Key *hostkey)
{
- longjmp(kexjmp, (int)hostkey);
+ kexjmp_key = hostkey;
+ longjmp(kexjmp, 1);
}
static int
xfree(c->c_kex);
c->c_kex = NULL;
packet_close();
- if (j < 0)
- j = 0;
- return (Key*)(j);
+ return j < 0? NULL : kexjmp_key;
}
static void
fprintf(stderr, " -p port Connect to the specified port.\n");
fprintf(stderr, " -t keytype Specify the host key type.\n");
fprintf(stderr, " -T timeout Set connection timeout.\n");
- fprintf(stderr, " -v Verbose; display verbose debugging messages.\n");
- fprintf(stderr, " -4 Use IPv4 only.\n");
- fprintf(stderr, " -6 Use IPv6 only.\n");
+ fprintf(stderr, " -v Verbose; display verbose debugging messages.\n");
+ fprintf(stderr, " -4 Use IPv4 only.\n");
+ fprintf(stderr, " -6 Use IPv6 only.\n");
exit(1);
}
int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO;
int opt, fopt_count = 0;
char *tname;
-
+
extern int optind;
extern char *optarg;
__progname = get_progname(argv[0]);
+ init_rng();
+ seed_rng();
TAILQ_INIT(&tq);
if (argc <= 1)
else
fatal("Too high debugging level.");
break;
- case 'f':
+ case 'f':
if (strcmp(optarg, "-") == 0)
optarg = NULL;
argv[fopt_count++] = optarg;
log_init("ssh-keyscan", log_level, SYSLOG_FACILITY_USER, 1);
fatal_add_cleanup(fatal_callback, NULL);
-
maxfd = fdlim_get(1);
if (maxfd < 0)
fatal("%s: fdlim_get: bad value", __progname);
for (j = 0; j < fopt_count; j++) {
lb = Linebuf_alloc(argv[j], error);
+ if (!lb)
+ continue;
while ((line = Linebuf_getline(lb)) != NULL)
do_host(line);
Linebuf_free(lb);