=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/sshconnect.c,v retrieving revision 1.79.2.5 retrieving revision 1.79.2.6 diff -u -r1.79.2.5 -r1.79.2.6 --- src/usr.bin/ssh/sshconnect.c 2001/09/27 00:15:43 1.79.2.5 +++ src/usr.bin/ssh/sshconnect.c 2001/11/15 00:15:00 1.79.2.6 @@ -13,7 +13,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect.c,v 1.79.2.5 2001/09/27 00:15:43 miod Exp $"); +RCSID("$OpenBSD: sshconnect.c,v 1.79.2.6 2001/11/15 00:15:00 miod Exp $"); #include @@ -38,9 +38,6 @@ extern Options options; extern char *__progname; -/* AF_UNSPEC or AF_INET or AF_INET6 */ -extern int IPv4or6; - static const char * sockaddr_ntop(struct sockaddr *sa) { @@ -200,7 +197,7 @@ return sock; memset(&hints, 0, sizeof(hints)); - hints.ai_family = IPv4or6; + hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; gaierr = getaddrinfo(options.bind_address, "0", &hints, &res); @@ -239,9 +236,8 @@ */ int ssh_connect(const char *host, struct sockaddr_storage * hostaddr, - u_short port, int connection_attempts, - int anonymous, struct passwd *pw, - const char *proxy_command) + u_short port, int family, int connection_attempts, + int anonymous, struct passwd *pw, const char *proxy_command) { int gaierr; int on = 1; @@ -275,7 +271,7 @@ /* No proxy command. */ memset(&hints, 0, sizeof(hints)); - hints.ai_family = IPv4or6; + hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; snprintf(strport, sizeof strport, "%d", port); if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) @@ -483,7 +479,7 @@ /* defaults to 'no' */ static int -read_yes_or_no(const char *prompt, int defval) +confirm(const char *prompt) { char buf[1024]; FILE *f; @@ -491,39 +487,28 @@ if (options.batch_mode) return 0; - if (isatty(STDIN_FILENO)) f = stdin; else f = fopen(_PATH_TTY, "rw"); - if (f == NULL) return 0; - fflush(stdout); - + fprintf(stderr, "%s", prompt); while (1) { - fprintf(stderr, "%s", prompt); if (fgets(buf, sizeof(buf), f) == NULL) { - /* - * Print a newline (the prompt probably didn\'t have - * one). - */ fprintf(stderr, "\n"); strlcpy(buf, "no", sizeof buf); } /* Remove newline from response. */ if (strchr(buf, '\n')) *strchr(buf, '\n') = 0; - - if (buf[0] == 0) - retval = defval; if (strcmp(buf, "yes") == 0) retval = 1; else if (strcmp(buf, "no") == 0) retval = 0; else - fprintf(stderr, "Please type 'yes' or 'no'.\n"); + fprintf(stderr, "Please type 'yes' or 'no': "); if (retval != -1) { if (f != stdin) @@ -575,7 +560,8 @@ local = 0; break; } - if (local && options.host_key_alias == NULL) { + if (options.no_host_authentication_for_localhost == 1 && local && + options.host_key_alias == NULL) { debug("Forcing accepting of host key for " "loopback/localhost."); return 0; @@ -700,8 +686,7 @@ "Are you sure you want to continue connecting " "(yes/no)? ", host, ip, type, fp); xfree(fp); - if (!read_yes_or_no(prompt, -1)) { - log("Aborted by user!"); + if (!confirm(prompt)) { goto fail; } } @@ -817,9 +802,8 @@ error("Exiting, you have requested strict checking."); goto fail; } else if (options.strict_host_key_checking == 2) { - if (!read_yes_or_no("Are you sure you want " - "to continue connecting (yes/no)? ", -1)) { - log("Aborted by user!"); + if (!confirm("Are you sure you want " + "to continue connecting (yes/no)? ")) { goto fail; } }