]> andersk Git - openssh.git/blobdiff - ssh-keyscan.c
- (dtucker) [sftp.c] Expand ifdef for libedit to cover complete_is_remote
[openssh.git] / ssh-keyscan.c
index 64d4d0870363b363d568a9e85f5d69d7cb392e91..086c0d345e2a703067f2fa16778c5e52df44ef29 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keyscan.c,v 1.73 2006/08/03 03:34:42 deraadt Exp $ */
+/* $OpenBSD: ssh-keyscan.c,v 1.80 2009/12/25 19:40:21 stevesk Exp $ */
 /*
  * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
  *
@@ -15,6 +15,9 @@
 # include <sys/time.h>
 #endif
 
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
 #include <openssl/bn.h>
 
 #include <netdb.h>
@@ -53,7 +56,7 @@ int ssh_port = SSH_DEFAULT_PORT;
 #define KT_DSA 2
 #define KT_RSA 4
 
-int get_keytypes = KT_RSA1;    /* Get only RSA1 keys by default */
+int get_keytypes = KT_RSA;     /* Get only RSA keys by default */
 
 int hash_hosts = 0;            /* Hash hostname on output */
 
@@ -65,6 +68,9 @@ int timeout = 5;
 int maxfd;
 #define MAXCON (maxfd - 10)
 
+/* The default routing domain */
+int scan_rdomain = -1;
+
 extern char *__progname;
 fd_set *read_wait;
 size_t read_wait_nfdset;
@@ -407,9 +413,10 @@ tcpconnect(char *host)
        hints.ai_family = IPv4or6;
        hints.ai_socktype = SOCK_STREAM;
        if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
-               fatal("getaddrinfo %s: %s", host, gai_strerror(gaierr));
+               fatal("getaddrinfo %s: %s", host, ssh_gai_strerror(gaierr));
        for (ai = aitop; ai; ai = ai->ai_next) {
-               s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+               s = socket_rdomain(ai->ai_family, ai->ai_socktype,
+                   ai->ai_protocol, scan_rdomain);
                if (s < 0) {
                        error("socket: %s", strerror(errno));
                        continue;
@@ -653,7 +660,7 @@ conloop(void)
        memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask));
 
        while (select(maxfd, r, NULL, e, &seltime) == -1 &&
-           (errno == EAGAIN || errno == EINTR))
+           (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
                ;
 
        for (i = 0; i < maxfd; i++) {
@@ -710,8 +717,9 @@ fatal(const char *fmt,...)
 static void
 usage(void)
 {
-       fprintf(stderr, "usage: %s [-46Hv] [-f file] [-p port] [-T timeout] [-t type]\n"
-           "\t\t   [host | addrlist namelist] [...]\n",
+       fprintf(stderr,
+           "usage: %s [-46Hv] [-f file] [-p port] [-T timeout] [-t type]\n"
+           "\t\t   [-V rdomain] [host | addrlist namelist] ...\n",
            __progname);
        exit(1);
 }
@@ -737,14 +745,14 @@ main(int argc, char **argv)
        if (argc <= 1)
                usage();
 
-       while ((opt = getopt(argc, argv, "Hv46p:T:t:f:")) != -1) {
+       while ((opt = getopt(argc, argv, "Hv46p:T:t:f:V:")) != -1) {
                switch (opt) {
                case 'H':
                        hash_hosts = 1;
                        break;
                case 'p':
                        ssh_port = a2port(optarg);
-                       if (ssh_port == 0) {
+                       if (ssh_port <= 0) {
                                fprintf(stderr, "Bad port '%s'\n", optarg);
                                exit(1);
                        }
@@ -798,6 +806,19 @@ main(int argc, char **argv)
                case '6':
                        IPv4or6 = AF_INET6;
                        break;
+               case 'V':
+#ifdef USE_ROUTINGDOMAIN
+                       scan_rdomain = a2rdomain(optarg);
+                       if (scan_rdomain == -1) {
+                               fprintf(stderr, "Bad rdomain '%s'\n", optarg);
+                               exit(1);
+                       }
+#else
+                       fprintf(stderr, "RoutingDomain not supported on this "
+                          "platform.\n");
+                       exit(1);
+#endif
+                       break;
                case '?':
                default:
                        usage();
This page took 0.118384 seconds and 4 git commands to generate.