]> andersk Git - openssh.git/blobdiff - ssh-keyscan.c
- markus@cvs.openbsd.org 2001/11/07 22:53:21
[openssh.git] / ssh-keyscan.c
index 3f8c5b4032eb0496cb79d2c850478aba73aef1a2..5204913925a7ac042cd121285b8fd023afc3695b 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #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>
@@ -36,19 +36,15 @@ RCSID("$OpenBSD: ssh-keyscan.c,v 1.27 2001/08/05 23:29:58 markus Exp $");
 
 /* 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
 
@@ -68,6 +64,7 @@ size_t read_wait_size;
 int ncon;
 int nonfatal_fatal = 0;
 jmp_buf kexjmp;
+Key *kexjmp_key;
 
 /*
  * Keep a connection structure for each file descriptor.  The state
@@ -322,7 +319,8 @@ keygrab_ssh1(con *c)
 static int
 hostjump(Key *hostkey)
 {
-       longjmp(kexjmp, (int)hostkey);
+       kexjmp_key = hostkey;
+       longjmp(kexjmp, 1);
 }
 
 static int
@@ -363,10 +361,8 @@ keygrab_ssh2(con *c)
        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
@@ -673,9 +669,9 @@ usage(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);
 }
 
@@ -685,11 +681,13 @@ main(int argc, char **argv)
        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)
@@ -719,7 +717,7 @@ main(int argc, char **argv)
                        else
                                fatal("Too high debugging level.");
                        break;
-                case 'f':
+               case 'f':
                        if (strcmp(optarg, "-") == 0)
                                optarg = NULL;
                        argv[fopt_count++] = optarg;
@@ -762,7 +760,6 @@ main(int argc, char **argv)
        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);
@@ -786,6 +783,8 @@ main(int argc, char **argv)
 
                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);
This page took 0.038783 seconds and 4 git commands to generate.