[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.72 and 1.72.2.3

version 1.72, 2000/05/04 09:50:22 version 1.72.2.3, 2000/11/08 21:31:27
Line 2 
Line 2 
  * Author: Tatu Ylonen <ylo@cs.hut.fi>   * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland   * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  *                    All rights reserved   *                    All rights reserved
  * Created: Sat Mar 18 22:15:47 1995 ylo  
  * Code to connect to a remote host, and to perform the client side of the   * Code to connect to a remote host, and to perform the client side of the
  * login (authentication) dialog.   * login (authentication) dialog.
    *
    * As far as I am concerned, the code I have written for this software
    * can be used freely for any purpose.  Any derived versions of this
    * software must be clearly marked as such, and if the derived work is
    * incompatible with the protocol description in the RFC file, it must be
    * called by a name other than "ssh" or "Secure Shell".
  */   */
   
 #include "includes.h"  #include "includes.h"
Line 189 
Line 194 
         int gaierr;          int gaierr;
         struct linger linger;          struct linger linger;
   
         debug("ssh_connect: getuid %d geteuid %d anon %d",          debug("ssh_connect: getuid %u geteuid %u anon %d",
               (int) getuid(), (int) geteuid(), anonymous);                (u_int) getuid(), (u_int) geteuid(), anonymous);
   
         /* Get default port if port has not been set. */          /* Get default port if port has not been set. */
         if (port == 0) {          if (port == 0) {
Line 251 
Line 256 
                         temporarily_use_uid(original_real_uid);                          temporarily_use_uid(original_real_uid);
                         if (connect(sock, ai->ai_addr, ai->ai_addrlen) >= 0) {                          if (connect(sock, ai->ai_addr, ai->ai_addrlen) >= 0) {
                                 /* Successful connection. */                                  /* Successful connection. */
                                 memcpy(hostaddr, ai->ai_addr, sizeof(*hostaddr));                                  memcpy(hostaddr, ai->ai_addr, ai->ai_addrlen);
                                 restore_uid();                                  restore_uid();
                                 break;                                  break;
                         } else {                          } else {
Line 297 
Line 302 
         return 1;          return 1;
 }  }
   
 char *  
 chop(char *s)  
 {  
         char *t = s;  
         while (*t) {  
                 if(*t == '\n' || *t == '\r') {  
                         *t = '\0';  
                         return s;  
                 }  
                 t++;  
         }  
         return s;  
   
 }  
   
 /*  /*
  * Waits for the server identification string, and sends our own   * Waits for the server identification string, and sends our own
  * identification string.   * identification string.
Line 325 
Line 315 
         int connection_out = packet_get_connection_out();          int connection_out = packet_get_connection_out();
   
         /* Read other side\'s version identification. */          /* Read other side\'s version identification. */
         for (i = 0; i < sizeof(buf) - 1; i++) {          for (;;) {
                 int len = read(connection_in, &buf[i], 1);                  for (i = 0; i < sizeof(buf) - 1; i++) {
                 if (len < 0)                          int len = atomicio(read, connection_in, &buf[i], 1);
                         fatal("ssh_exchange_identification: read: %.100s", strerror(errno));                          if (len < 0)
                 if (len != 1)                                  fatal("ssh_exchange_identification: read: %.100s", strerror(errno));
                         fatal("ssh_exchange_identification: Connection closed by remote host");                          if (len != 1)
                 if (buf[i] == '\r') {                                  fatal("ssh_exchange_identification: Connection closed by remote host");
                         buf[i] = '\n';                          if (buf[i] == '\r') {
                         buf[i + 1] = 0;                                  buf[i] = '\n';
                         continue;               /**XXX wait for \n */                                  buf[i + 1] = 0;
                                   continue;               /**XXX wait for \n */
                           }
                           if (buf[i] == '\n') {
                                   buf[i + 1] = 0;
                                   break;
                           }
                 }                  }
                 if (buf[i] == '\n') {                  buf[sizeof(buf) - 1] = 0;
                         buf[i + 1] = 0;                  if (strncmp(buf, "SSH-", 4) == 0)
                         break;                          break;
                 }                  debug("ssh_exchange_identification: %s", buf);
         }          }
         buf[sizeof(buf) - 1] = 0;  
         server_version_string = xstrdup(buf);          server_version_string = xstrdup(buf);
   
         /*          /*
Line 441 
Line 436 
                         retval = defval;                          retval = defval;
                 if (strcmp(buf, "yes") == 0)                  if (strcmp(buf, "yes") == 0)
                         retval = 1;                          retval = 1;
                 if (strcmp(buf, "no") == 0)                  else if (strcmp(buf, "no") == 0)
                         retval = 0;                          retval = 0;
                   else
                           fprintf(stderr, "Please type 'yes' or 'no'.\n");
   
                 if (retval != -1) {                  if (retval != -1) {
                         if (f != stdin)                          if (f != stdin)
Line 671 
Line 668 
         /* Get local user name.  Use it as server user if no user name was given. */          /* Get local user name.  Use it as server user if no user name was given. */
         pw = getpwuid(original_real_uid);          pw = getpwuid(original_real_uid);
         if (!pw)          if (!pw)
                 fatal("User id %d not found from user database.", original_real_uid);                  fatal("User id %u not found from user database.", original_real_uid);
         local_user = xstrdup(pw->pw_name);          local_user = xstrdup(pw->pw_name);
         server_user = options.user ? options.user : local_user;          server_user = options.user ? options.user : local_user;
   

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.72.2.3