[BACK]Return to sshconnect.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/sshconnect.c between version 1.111 and 1.112

version 1.111, 2001/10/01 21:51:16 version 1.112, 2001/10/06 00:14:50
Line 483 
Line 483 
   
 /* defaults to 'no' */  /* defaults to 'no' */
 static int  static int
 read_yes_or_no(const char *prompt, int defval)  confirm(const char *prompt)
 {  {
         char buf[1024];          char buf[1024];
         FILE *f;          FILE *f;
Line 491 
Line 491 
   
         if (options.batch_mode)          if (options.batch_mode)
                 return 0;                  return 0;
   
         if (isatty(STDIN_FILENO))          if (isatty(STDIN_FILENO))
                 f = stdin;                  f = stdin;
         else          else
                 f = fopen(_PATH_TTY, "rw");                  f = fopen(_PATH_TTY, "rw");
   
         if (f == NULL)          if (f == NULL)
                 return 0;                  return 0;
   
         fflush(stdout);          fflush(stdout);
   
         while (1) {          while (1) {
                 fprintf(stderr, "%s", prompt);                  fprintf(stderr, "%s", prompt);
                 if (fgets(buf, sizeof(buf), f) == NULL) {                  if (fgets(buf, sizeof(buf), f) == NULL) {
                         /*  
                          * Print a newline (the prompt probably didn\'t have  
                          * one).  
                          */  
                         fprintf(stderr, "\n");                          fprintf(stderr, "\n");
                         strlcpy(buf, "no", sizeof buf);                          strlcpy(buf, "no", sizeof buf);
                 }                  }
                 /* Remove newline from response. */                  /* Remove newline from response. */
                 if (strchr(buf, '\n'))                  if (strchr(buf, '\n'))
                         *strchr(buf, '\n') = 0;                          *strchr(buf, '\n') = 0;
   
                 if (buf[0] == 0)  
                         retval = defval;  
                 if (strcmp(buf, "yes") == 0)                  if (strcmp(buf, "yes") == 0)
                         retval = 1;                          retval = 1;
                 else if (strcmp(buf, "no") == 0)                  else if (strcmp(buf, "no") == 0)
Line 701 
Line 690 
                             "Are you sure you want to continue connecting "                              "Are you sure you want to continue connecting "
                             "(yes/no)? ", host, ip, type, fp);                              "(yes/no)? ", host, ip, type, fp);
                         xfree(fp);                          xfree(fp);
                         if (!read_yes_or_no(prompt, -1)) {                          if (!confirm(prompt)) {
                                 log("Aborted by user!");                                  log("Aborted by user!");
                                 goto fail;                                  goto fail;
                         }                          }
Line 818 
Line 807 
                         error("Exiting, you have requested strict checking.");                          error("Exiting, you have requested strict checking.");
                         goto fail;                          goto fail;
                 } else if (options.strict_host_key_checking == 2) {                  } else if (options.strict_host_key_checking == 2) {
                         if (!read_yes_or_no("Are you sure you want "                          if (!confirm("Are you sure you want "
                             "to continue connecting (yes/no)? ", -1)) {                              "to continue connecting (yes/no)? ")) {
                                 log("Aborted by user!");                                  log("Aborted by user!");
                                 goto fail;                                  goto fail;
                         }                          }

Legend:
Removed from v.1.111  
changed lines
  Added in v.1.112