[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.180.2.1 and 1.180.2.2

version 1.180.2.1, 2005/03/10 16:28:27 version 1.180.2.2, 2005/09/02 03:45:00
Line 56 
Line 56 
 #include "serverloop.h"  #include "serverloop.h"
 #include "canohost.h"  #include "canohost.h"
 #include "session.h"  #include "session.h"
   #include "kex.h"
 #include "monitor_wrap.h"  #include "monitor_wrap.h"
   
 #ifdef KRB5  #ifdef KRB5
Line 193 
Line 194 
 static void  static void
 display_loginmsg(void)  display_loginmsg(void)
 {  {
         if (buffer_len(&loginmsg) > 0) {          if (buffer_len(&loginmsg) > 0) {
                 buffer_append(&loginmsg, "\0", 1);                  buffer_append(&loginmsg, "\0", 1);
                 printf("%s", (char *)buffer_ptr(&loginmsg));                  printf("%s", (char *)buffer_ptr(&loginmsg));
                 buffer_clear(&loginmsg);                  buffer_clear(&loginmsg);
         }          }
 }  }
   
 void  void
Line 269 
Line 270 
                                     compression_level);                                      compression_level);
                                 break;                                  break;
                         }                          }
                         if (!options.compression) {                          if (options.compression == COMP_NONE) {
                                 debug2("compression disabled");                                  debug2("compression disabled");
                                 break;                                  break;
                         }                          }
Line 1173 
Line 1174 
          */           */
   
         if (options.kerberos_get_afs_token && k_hasafs() &&          if (options.kerberos_get_afs_token && k_hasafs() &&
              (s->authctxt->krb5_ctx != NULL)) {              (s->authctxt->krb5_ctx != NULL)) {
                 char cell[64];                  char cell[64];
   
                 debug("Getting AFS token");                  debug("Getting AFS token");
Line 1277 
Line 1278 
                         s->ttyfd = -1;                          s->ttyfd = -1;
                         s->used = 1;                          s->used = 1;
                         s->self = i;                          s->self = i;
                           s->x11_chanids = NULL;
                         debug("session_new: session %d", i);                          debug("session_new: session %d", i);
                         return s;                          return s;
                 }                  }
Line 1350 
Line 1352 
 }  }
   
 static Session *  static Session *
   session_by_x11_channel(int id)
   {
           int i, j;
   
           for (i = 0; i < MAX_SESSIONS; i++) {
                   Session *s = &sessions[i];
   
                   if (s->x11_chanids == NULL || !s->used)
                           continue;
                   for (j = 0; s->x11_chanids[j] != -1; j++) {
                           if (s->x11_chanids[j] == id) {
                                   debug("session_by_x11_channel: session %d "
                                       "channel %d", s->self, id);
                                   return s;
                           }
                   }
           }
           debug("session_by_x11_channel: unknown channel %d", id);
           session_dump();
           return NULL;
   }
   
   static Session *
 session_by_pid(pid_t pid)  session_by_pid(pid_t pid)
 {  {
         int i;          int i;
Line 1444 
Line 1469 
         u_int len;          u_int len;
         int success = 0;          int success = 0;
         char *cmd, *subsys = packet_get_string(&len);          char *cmd, *subsys = packet_get_string(&len);
         int i;          u_int i;
   
         packet_check_eom();          packet_check_eom();
         logit("subsystem request for %.100s", subsys);          logit("subsystem request for %.100s", subsys);
Line 1478 
Line 1503 
 {  {
         int success;          int success;
   
           if (s->auth_proto != NULL || s->auth_data != NULL) {
                   error("session_x11_req: session %d: "
                       "x11 fowarding already active", s->self);
                   return 0;
           }
         s->single_connection = packet_get_char();          s->single_connection = packet_get_char();
         s->auth_proto = packet_get_string(NULL);          s->auth_proto = packet_get_string(NULL);
         s->auth_data = packet_get_string(NULL);          s->auth_data = packet_get_string(NULL);
Line 1703 
Line 1733 
 }  }
   
 static void  static void
   session_close_x11(int id)
   {
           Channel *c;
   
           if ((c = channel_lookup(id)) == NULL) {
                   debug("session_close_x11: x11 channel %d missing", id);
           } else {
                   /* Detach X11 listener */
                   debug("session_close_x11: detach x11 channel %d", id);
                   channel_cancel_cleanup(id);
                   if (c->ostate != CHAN_OUTPUT_CLOSED)
                           chan_mark_dead(c);
           }
   }
   
   static void
   session_close_single_x11(int id, void *arg)
   {
           Session *s;
           u_int i;
   
           debug3("session_close_single_x11: channel %d", id);
           channel_cancel_cleanup(id);
           if ((s  = session_by_x11_channel(id)) == NULL)
                   fatal("session_close_single_x11: no x11 channel %d", id);
           for (i = 0; s->x11_chanids[i] != -1; i++) {
                   debug("session_close_single_x11: session %d: "
                       "closing channel %d", s->self, s->x11_chanids[i]);
                   /*
                    * The channel "id" is already closing, but make sure we
                    * close all of its siblings.
                    */
                   if (s->x11_chanids[i] != id)
                           session_close_x11(s->x11_chanids[i]);
           }
           xfree(s->x11_chanids);
           s->x11_chanids = NULL;
           if (s->display) {
                   xfree(s->display);
                   s->display = NULL;
           }
           if (s->auth_proto) {
                   xfree(s->auth_proto);
                   s->auth_proto = NULL;
           }
           if (s->auth_data) {
                   xfree(s->auth_data);
                   s->auth_data = NULL;
           }
           if (s->auth_display) {
                   xfree(s->auth_display);
                   s->auth_display = NULL;
           }
   }
   
   static void
 session_exit_message(Session *s, int status)  session_exit_message(Session *s, int status)
 {  {
         Channel *c;          Channel *c;
           u_int i;
   
         if ((c = channel_lookup(s->chanid)) == NULL)          if ((c = channel_lookup(s->chanid)) == NULL)
                 fatal("session_exit_message: session %d: no channel %d",                  fatal("session_exit_message: session %d: no channel %d",
Line 1741 
Line 1828 
         if (c->ostate != CHAN_OUTPUT_CLOSED)          if (c->ostate != CHAN_OUTPUT_CLOSED)
                 chan_write_failed(c);                  chan_write_failed(c);
         s->chanid = -1;          s->chanid = -1;
   
           /* Close any X11 listeners associated with this session */
           if (s->x11_chanids != NULL) {
                   for (i = 0; s->x11_chanids[i] != -1; i++) {
                           session_close_x11(s->x11_chanids[i]);
                           s->x11_chanids[i] = -1;
                   }
           }
 }  }
   
 void  void
 session_close(Session *s)  session_close(Session *s)
 {  {
         int i;          u_int i;
   
         debug("session_close: session %d pid %ld", s->self, (long)s->pid);          debug("session_close: session %d pid %ld", s->self, (long)s->pid);
         if (s->ttyfd != -1)          if (s->ttyfd != -1)
Line 1755 
Line 1850 
                 xfree(s->term);                  xfree(s->term);
         if (s->display)          if (s->display)
                 xfree(s->display);                  xfree(s->display);
           if (s->x11_chanids)
                   xfree(s->x11_chanids);
         if (s->auth_display)          if (s->auth_display)
                 xfree(s->auth_display);                  xfree(s->auth_display);
         if (s->auth_data)          if (s->auth_data)
Line 1793 
Line 1890 
 session_close_by_channel(int id, void *arg)  session_close_by_channel(int id, void *arg)
 {  {
         Session *s = session_by_channel(id);          Session *s = session_by_channel(id);
   
         if (s == NULL) {          if (s == NULL) {
                 debug("session_close_by_channel: no session for id %d", id);                  debug("session_close_by_channel: no session for id %d", id);
                 return;                  return;
Line 1864 
Line 1962 
         struct stat st;          struct stat st;
         char display[512], auth_display[512];          char display[512], auth_display[512];
         char hostname[MAXHOSTNAMELEN];          char hostname[MAXHOSTNAMELEN];
           u_int i;
   
         if (no_x11_forwarding_flag) {          if (no_x11_forwarding_flag) {
                 packet_send_debug("X11 forwarding disabled in user configuration file.");                  packet_send_debug("X11 forwarding disabled in user configuration file.");
Line 1889 
Line 1988 
         }          }
         if (x11_create_display_inet(options.x11_display_offset,          if (x11_create_display_inet(options.x11_display_offset,
             options.x11_use_localhost, s->single_connection,              options.x11_use_localhost, s->single_connection,
             &s->display_number) == -1) {              &s->display_number, &s->x11_chanids) == -1) {
                 debug("x11_create_display_inet failed.");                  debug("x11_create_display_inet failed.");
                 return 0;                  return 0;
           }
           for (i = 0; s->x11_chanids[i] != -1; i++) {
                   channel_register_cleanup(s->x11_chanids[i],
                       session_close_single_x11);
         }          }
   
         /* Set up a suitable value for the DISPLAY variable. */          /* Set up a suitable value for the DISPLAY variable. */

Legend:
Removed from v.1.180.2.1  
changed lines
  Added in v.1.180.2.2