[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.255 and 1.256

version 1.255, 2010/06/22 04:59:12 version 1.256, 2010/06/25 07:20:04
Line 97 
Line 97 
 /* func */  /* func */
   
 Session *session_new(void);  Session *session_new(void);
 void    session_set_fds(Session *, int, int, int, int);  void    session_set_fds(Session *, int, int, int, int, int);
 void    session_pty_cleanup(Session *);  void    session_pty_cleanup(Session *);
 void    session_proctitle(Session *);  void    session_proctitle(Session *);
 int     session_setup_x11fwd(Session *);  int     session_setup_x11fwd(Session *);
Line 448 
Line 448 
                 close(pin[1]);                  close(pin[1]);
                 return -1;                  return -1;
         }          }
         if (s->is_subsystem) {          if (pipe(perr) < 0) {
                 if ((perr[1] = open(_PATH_DEVNULL, O_WRONLY)) == -1) {                  error("%s: pipe err: %.100s", __func__,
                         error("%s: open(%s): %s", __func__, _PATH_DEVNULL,                      strerror(errno));
                             strerror(errno));                  close(pin[0]);
                         close(pin[0]);                  close(pin[1]);
                         close(pin[1]);                  close(pout[0]);
                         close(pout[0]);                  close(pout[1]);
                         close(pout[1]);                  return -1;
                         return -1;  
                 }  
                 perr[0] = -1;  
         } else {  
                 if (pipe(perr) < 0) {  
                         error("%s: pipe err: %.100s", __func__,  
                             strerror(errno));  
                         close(pin[0]);  
                         close(pin[1]);  
                         close(pout[0]);  
                         close(pout[1]);  
                         return -1;  
                 }  
         }          }
 #else  #else
         int inout[2], err[2];          int inout[2], err[2];
Line 481 
Line 468 
                 error("%s: socketpair #1: %.100s", __func__, strerror(errno));                  error("%s: socketpair #1: %.100s", __func__, strerror(errno));
                 return -1;                  return -1;
         }          }
         if (s->is_subsystem) {          if (socketpair(AF_UNIX, SOCK_STREAM, 0, err) < 0) {
                 if ((err[0] = open(_PATH_DEVNULL, O_WRONLY)) == -1) {                  error("%s: socketpair #2: %.100s", __func__,
                         error("%s: open(%s): %s", __func__, _PATH_DEVNULL,                      strerror(errno));
                             strerror(errno));                  close(inout[0]);
                         close(inout[0]);                  close(inout[1]);
                         close(inout[1]);                  return -1;
                         return -1;  
                 }  
                 err[1] = -1;  
         } else {  
                 if (socketpair(AF_UNIX, SOCK_STREAM, 0, err) < 0) {  
                         error("%s: socketpair #2: %.100s", __func__,  
                             strerror(errno));  
                         close(inout[0]);  
                         close(inout[1]);  
                         return -1;  
                 }  
         }          }
 #endif  #endif
   
Line 512 
Line 488 
                 close(pin[1]);                  close(pin[1]);
                 close(pout[0]);                  close(pout[0]);
                 close(pout[1]);                  close(pout[1]);
                 if (perr[0] != -1)                  close(perr[0]);
                         close(perr[0]);  
                 close(perr[1]);                  close(perr[1]);
 #else  #else
                 close(inout[0]);                  close(inout[0]);
                 close(inout[1]);                  close(inout[1]);
                 close(err[0]);                  close(err[0]);
                 if (err[1] != -1)                  close(err[1]);
                         close(err[1]);  
 #endif  #endif
                 return -1;                  return -1;
         case 0:          case 0:
Line 554 
Line 528 
                 close(pout[1]);                  close(pout[1]);
   
                 /* Redirect stderr. */                  /* Redirect stderr. */
                 if (perr[0] != -1)                  close(perr[0]);
                         close(perr[0]);  
                 if (dup2(perr[1], 2) < 0)                  if (dup2(perr[1], 2) < 0)
                         perror("dup2 stderr");                          perror("dup2 stderr");
                 close(perr[1]);                  close(perr[1]);
Line 566 
Line 539 
                  * seem to depend on it.                   * seem to depend on it.
                  */                   */
                 close(inout[1]);                  close(inout[1]);
                 if (err[1] != -1)                  close(err[1]);
                         close(err[1]);  
                 if (dup2(inout[0], 0) < 0)      /* stdin */                  if (dup2(inout[0], 0) < 0)      /* stdin */
                         perror("dup2 stdin");                          perror("dup2 stdin");
                 if (dup2(inout[0], 1) < 0)      /* stdout (same as stdin) */                  if (dup2(inout[0], 1) < 0)      /* stdout (same as stdin) */
Line 596 
Line 568 
         close(perr[1]);          close(perr[1]);
   
         if (compat20) {          if (compat20) {
                 session_set_fds(s, pin[1], pout[0], perr[0], 0);                  session_set_fds(s, pin[1], pout[0], perr[0],
                       s->is_subsystem, 0);
         } else {          } else {
                 /* Enter the interactive session. */                  /* Enter the interactive session. */
                 server_loop(pid, pin[1], pout[0], perr[0]);                  server_loop(pid, pin[1], pout[0], perr[0]);
Line 612 
Line 585 
          * handle the case that fdin and fdout are the same.           * handle the case that fdin and fdout are the same.
          */           */
         if (compat20) {          if (compat20) {
                 session_set_fds(s, inout[1], inout[1], err[1], 0);                  session_set_fds(s, inout[1], inout[1], err[1],
                       s->is_subsystem, 0);
         } else {          } else {
                 server_loop(pid, inout[1], inout[1], err[1]);                  server_loop(pid, inout[1], inout[1], err[1]);
                 /* server_loop has closed inout[1] and err[1]. */                  /* server_loop has closed inout[1] and err[1]. */
Line 717 
Line 691 
         s->ptymaster = ptymaster;          s->ptymaster = ptymaster;
         packet_set_interactive(1);          packet_set_interactive(1);
         if (compat20) {          if (compat20) {
                 session_set_fds(s, ptyfd, fdout, -1, 1);                  session_set_fds(s, ptyfd, fdout, -1, 1, 1);
         } else {          } else {
                 server_loop(pid, ptyfd, fdout, -1);                  server_loop(pid, ptyfd, fdout, -1);
                 /* server_loop _has_ closed ptyfd and fdout. */                  /* server_loop _has_ closed ptyfd and fdout. */
Line 1936 
Line 1910 
 }  }
   
 void  void
 session_set_fds(Session *s, int fdin, int fdout, int fderr, int is_tty)  session_set_fds(Session *s, int fdin, int fdout, int fderr, int ignore_fderr,
       int is_tty)
 {  {
         if (!compat20)          if (!compat20)
                 fatal("session_set_fds: called for proto != 2.0");                  fatal("session_set_fds: called for proto != 2.0");
Line 1948 
Line 1923 
                 fatal("no channel for session %d", s->self);                  fatal("no channel for session %d", s->self);
         channel_set_fds(s->chanid,          channel_set_fds(s->chanid,
             fdout, fdin, fderr,              fdout, fdin, fderr,
             fderr == -1 ? CHAN_EXTENDED_IGNORE : CHAN_EXTENDED_READ,              ignore_fderr ? CHAN_EXTENDED_IGNORE : CHAN_EXTENDED_READ,
             1, is_tty, CHAN_SES_WINDOW_DEFAULT);              1, is_tty, CHAN_SES_WINDOW_DEFAULT);
 }  }
   

Legend:
Removed from v.1.255  
changed lines
  Added in v.1.256