=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/sshconnect.c,v retrieving revision 1.111 retrieving revision 1.112 diff -u -r1.111 -r1.112 --- src/usr.bin/ssh/sshconnect.c 2001/10/01 21:51:16 1.111 +++ src/usr.bin/ssh/sshconnect.c 2001/10/06 00:14:50 1.112 @@ -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 @@ -483,7 +483,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,33 +491,22 @@ 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 @@ "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 @@ 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; }