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

Diff for /src/usr.bin/ssh/session.c between version 1.85 and 1.86

version 1.85, 2001/06/12 10:58:29 version 1.86, 2001/06/12 16:10:38
Line 87 
Line 87 
 Session *session_new(void);  Session *session_new(void);
 void    session_set_fds(Session *s, int fdin, int fdout, int fderr);  void    session_set_fds(Session *s, int fdin, int fdout, int fderr);
 void    session_pty_cleanup(void *session);  void    session_pty_cleanup(void *session);
   int     session_pty_req(Session *s);
 void    session_proctitle(Session *s);  void    session_proctitle(Session *s);
 int     session_setup_x11fwd(Session *s);  int     session_setup_x11fwd(Session *s);
 void    session_close(Session *s);  void    session_close(Session *s);
Line 199 
Line 200 
 {  {
         Session *s;          Session *s;
         char *command;          char *command;
         int success, type, n_bytes, plen, screen_flag, have_pty = 0;          int success, type, plen, screen_flag;
         int compression_level = 0, enable_compression_after_reply = 0;          int compression_level = 0, enable_compression_after_reply = 0;
         u_int proto_len, data_len, dlen;          u_int proto_len, data_len, dlen;
   
Line 232 
Line 233 
                         break;                          break;
   
                 case SSH_CMSG_REQUEST_PTY:                  case SSH_CMSG_REQUEST_PTY:
                         if (no_pty_flag) {                          success = session_pty_req(s);
                                 debug("Allocating a pty not permitted for this authentication.");  
                                 break;  
                         }  
                         if (have_pty)  
                                 packet_disconnect("Protocol error: you already have a pty.");  
   
                         debug("Allocating pty.");  
   
                         /* Allocate a pty and open it. */  
                         if (!pty_allocate(&s->ptyfd, &s->ttyfd, s->tty,  
                             sizeof(s->tty))) {  
                                 error("Failed to allocate pty.");  
                                 break;  
                         }  
                         fatal_add_cleanup(session_pty_cleanup, (void *)s);  
                         pty_setowner(s->pw, s->tty);  
   
                         /* Get TERM from the packet.  Note that the value may be of arbitrary length. */  
                         s->term = packet_get_string(&dlen);  
                         packet_integrity_check(dlen, strlen(s->term), type);  
                         /* packet_integrity_check(plen, 4 + dlen + 4*4 + n_bytes, type); */  
                         /* Remaining bytes */  
                         n_bytes = plen - (4 + dlen + 4 * 4);  
   
                         if (strcmp(s->term, "") == 0) {  
                                 xfree(s->term);  
                                 s->term = NULL;  
                         }  
                         /* Get window size from the packet. */  
                         s->row = packet_get_int();  
                         s->col = packet_get_int();  
                         s->xpixel = packet_get_int();  
                         s->ypixel = packet_get_int();  
                         pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel);  
   
                         /* Get tty modes from the packet. */  
                         tty_parse_modes(s->ttyfd, &n_bytes);  
                         packet_integrity_check(plen, 4 + dlen + 4 * 4 + n_bytes, type);  
   
                         session_proctitle(s);  
   
                         /* Indicate that we now have a pty. */  
                         success = 1;  
                         have_pty = 1;  
                         break;                          break;
   
                 case SSH_CMSG_X11_REQUEST_FORWARDING:                  case SSH_CMSG_X11_REQUEST_FORWARDING:
Line 348 
Line 305 
                                 command = forced_command;                                  command = forced_command;
                                 debug("Forced command '%.500s'", forced_command);                                  debug("Forced command '%.500s'", forced_command);
                         }                          }
                         if (have_pty)                          if (s->ttyfd != -1)
                                 do_exec_pty(s, command);                                  do_exec_pty(s, command);
                         else                          else
                                 do_exec_no_pty(s, command);                                  do_exec_no_pty(s, command);
Line 1253 
Line 1210 
         u_int len;          u_int len;
         int n_bytes;          int n_bytes;
   
         if (no_pty_flag)          if (no_pty_flag) {
                   debug("Allocating a pty not permitted for this authentication.");
                 return 0;                  return 0;
         if (s->ttyfd != -1)          }
           if (s->ttyfd != -1) {
                   packet_disconnect("Protocol error: you already have a pty.");
                 return 0;                  return 0;
           }
   
         s->term = packet_get_string(&len);          s->term = packet_get_string(&len);
         s->col = packet_get_int();  
         s->row = packet_get_int();          if (compat20) {
                   s->col = packet_get_int();
                   s->row = packet_get_int();
           } else {
                   s->row = packet_get_int();
                   s->col = packet_get_int();
           }
         s->xpixel = packet_get_int();          s->xpixel = packet_get_int();
         s->ypixel = packet_get_int();          s->ypixel = packet_get_int();
   
Line 1267 
Line 1235 
                 xfree(s->term);                  xfree(s->term);
                 s->term = NULL;                  s->term = NULL;
         }          }
   
         /* Allocate a pty and open it. */          /* Allocate a pty and open it. */
           debug("Allocating pty.");
         if (!pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty))) {          if (!pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty))) {
                 xfree(s->term);                  if (s->term)
                           xfree(s->term);
                 s->term = NULL;                  s->term = NULL;
                 s->ptyfd = -1;                  s->ptyfd = -1;
                 s->ttyfd = -1;                  s->ttyfd = -1;
Line 1277 
Line 1248 
                 return 0;                  return 0;
         }          }
         debug("session_pty_req: session %d alloc %s", s->self, s->tty);          debug("session_pty_req: session %d alloc %s", s->self, s->tty);
   
           /* for SSH1 the tty modes length is not given */
           if (!compat20)
                   n_bytes = packet_remaining();
           tty_parse_modes(s->ttyfd, &n_bytes);
   
         /*          /*
          * Add a cleanup function to clear the utmp entry and record logout           * Add a cleanup function to clear the utmp entry and record logout
          * time in case we call fatal() (e.g., the connection gets closed).           * time in case we call fatal() (e.g., the connection gets closed).
          */           */
         fatal_add_cleanup(session_pty_cleanup, (void *)s);          fatal_add_cleanup(session_pty_cleanup, (void *)s);
         pty_setowner(s->pw, s->tty);          pty_setowner(s->pw, s->tty);
         /* Get window size from the packet. */  
           /* Set window size from the packet. */
         pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel);          pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel);
   
         /* Get tty modes from the packet. */  
         tty_parse_modes(s->ttyfd, &n_bytes);  
         packet_done();          packet_done();
   
         session_proctitle(s);          session_proctitle(s);
   
         return 1;          return 1;
 }  }
   

Legend:
Removed from v.1.85  
changed lines
  Added in v.1.86