diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/sshconnect.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c index 2e559115667..2c61af35177 100644 --- a/usr.bin/ssh/sshconnect.c +++ b/usr.bin/ssh/sshconnect.c @@ -13,7 +13,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect.c,v 1.111 2001/10/01 21:51:16 markus Exp $"); +RCSID("$OpenBSD: sshconnect.c,v 1.112 2001/10/06 00:14:50 markus Exp $"); #include <openssl/bn.h> @@ -483,7 +483,7 @@ ssh_exchange_identification(void) /* defaults to 'no' */ static int -read_yes_or_no(const char *prompt, int defval) +confirm(const char *prompt) { char buf[1024]; FILE *f; @@ -491,33 +491,22 @@ read_yes_or_no(const char *prompt, int defval) 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); - 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) @@ -701,7 +690,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, "Are you sure you want to continue connecting " "(yes/no)? ", host, ip, type, fp); xfree(fp); - if (!read_yes_or_no(prompt, -1)) { + if (!confirm(prompt)) { log("Aborted by user!"); goto fail; } @@ -818,8 +807,8 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, 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)) { + if (!confirm("Are you sure you want " + "to continue connecting (yes/no)? ")) { log("Aborted by user!"); goto fail; } |