[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.280 and 1.281

version 1.280, 2016/02/16 03:37:48 version 1.281, 2016/03/07 19:02:43
Line 695 
Line 695 
 int  int
 do_exec(Session *s, const char *command)  do_exec(Session *s, const char *command)
 {  {
           struct ssh *ssh = active_state; /* XXX */
         int ret;          int ret;
         const char *forced = NULL, *tty = NULL;          const char *forced = NULL, *tty = NULL;
         char session_type[1024];          char session_type[1024];
Line 737 
Line 738 
             tty == NULL ? "" : " on ",              tty == NULL ? "" : " on ",
             tty == NULL ? "" : tty,              tty == NULL ? "" : tty,
             s->pw->pw_name,              s->pw->pw_name,
             get_remote_ipaddr(),              ssh_remote_ipaddr(ssh),
             get_remote_port(),              ssh_remote_port(ssh),
             s->self);              s->self);
   
 #ifdef GSSAPI  #ifdef GSSAPI
Line 770 
Line 771 
 void  void
 do_login(Session *s, const char *command)  do_login(Session *s, const char *command)
 {  {
           struct ssh *ssh = active_state; /* XXX */
         socklen_t fromlen;          socklen_t fromlen;
         struct sockaddr_storage from;          struct sockaddr_storage from;
         struct passwd * pw = s->pw;          struct passwd * pw = s->pw;
Line 792 
Line 794 
         /* Record that there was a login on that tty from the remote host. */          /* Record that there was a login on that tty from the remote host. */
         if (!use_privsep)          if (!use_privsep)
                 record_login(pid, s->tty, pw->pw_name, pw->pw_uid,                  record_login(pid, s->tty, pw->pw_name, pw->pw_uid,
                     get_remote_name_or_ip(utmp_len,                      session_get_remote_name_or_ip(ssh, utmp_len,
                     options.use_dns),                      options.use_dns),
                     (struct sockaddr *)&from, fromlen);                      (struct sockaddr *)&from, fromlen);
   
Line 942 
Line 944 
 static char **  static char **
 do_setup_env(Session *s, const char *shell)  do_setup_env(Session *s, const char *shell)
 {  {
           struct ssh *ssh = active_state; /* XXX */
         char buf[256];          char buf[256];
         u_int i, envsize;          u_int i, envsize;
         char **env, *laddr;          char **env, *laddr;
Line 1003 
Line 1006 
   
         /* SSH_CLIENT deprecated */          /* SSH_CLIENT deprecated */
         snprintf(buf, sizeof buf, "%.50s %d %d",          snprintf(buf, sizeof buf, "%.50s %d %d",
             get_remote_ipaddr(), get_remote_port(), get_local_port());              ssh_remote_ipaddr(ssh), ssh_remote_port(ssh),
               ssh_local_port(ssh));
         child_set_env(&env, &envsize, "SSH_CLIENT", buf);          child_set_env(&env, &envsize, "SSH_CLIENT", buf);
   
         laddr = get_local_ipaddr(packet_get_connection_in());          laddr = get_local_ipaddr(packet_get_connection_in());
         snprintf(buf, sizeof buf, "%.50s %d %.50s %d",          snprintf(buf, sizeof buf, "%.50s %d %.50s %d",
             get_remote_ipaddr(), get_remote_port(), laddr, get_local_port());              ssh_remote_ipaddr(ssh), ssh_remote_port(ssh),
               laddr, ssh_local_port(ssh));
         free(laddr);          free(laddr);
         child_set_env(&env, &envsize, "SSH_CONNECTION", buf);          child_set_env(&env, &envsize, "SSH_CONNECTION", buf);
   
Line 1321 
Line 1326 
 void  void
 do_child(Session *s, const char *command)  do_child(Session *s, const char *command)
 {  {
           struct ssh *ssh = active_state; /* XXX */
         extern char **environ;          extern char **environ;
         char **env;          char **env;
         char *argv[ARGV_MAX];          char *argv[ARGV_MAX];
Line 1368 
Line 1374 
   
         /* we have to stash the hostname before we close our socket. */          /* we have to stash the hostname before we close our socket. */
         if (options.use_login)          if (options.use_login)
                 hostname = get_remote_name_or_ip(utmp_len,                  hostname = session_get_remote_name_or_ip(ssh, utmp_len,
                     options.use_dns);                      options.use_dns);
         /*          /*
          * Close the connection descriptors; note that this is the child, and           * Close the connection descriptors; note that this is the child, and
          * the server will still have the socket open, and it is important           * the server will still have the socket open, and it is important
          * that we do not shutdown it.  Note that the descriptors cannot be           * that we do not shutdown it.  Note that the descriptors cannot be
          * closed before building the environment, as we call           * closed before building the environment, as we call
          * get_remote_ipaddr there.           * ssh_remote_ipaddr there.
          */           */
         child_close_fds();          child_close_fds();
   
Line 2119 
Line 2125 
 void  void
 session_close(Session *s)  session_close(Session *s)
 {  {
           struct ssh *ssh = active_state; /* XXX */
         u_int i;          u_int i;
   
         verbose("Close session: user %s from %.200s port %d id %d",          verbose("Close session: user %s from %.200s port %d id %d",
             s->pw->pw_name,              s->pw->pw_name,
             get_remote_ipaddr(),              ssh_remote_ipaddr(ssh),
             get_remote_port(),              ssh_remote_port(ssh),
             s->self);              s->self);
   
         if (s->ttyfd != -1)          if (s->ttyfd != -1)
Line 2358 
Line 2365 
         if (!use_privsep || mm_is_monitor())          if (!use_privsep || mm_is_monitor())
                 session_destroy_all(session_pty_cleanup2);                  session_destroy_all(session_pty_cleanup2);
 }  }
   
   /* Return a name for the remote host that fits inside utmp_size */
   
   const char *
   session_get_remote_name_or_ip(struct ssh *ssh, u_int utmp_size, int use_dns)
   {
           const char *remote = "";
   
           if (utmp_size > 0)
                   remote = auth_get_canonical_hostname(ssh, use_dns);
           if (utmp_size == 0 || strlen(remote) > utmp_size)
                   remote = ssh_remote_ipaddr(ssh);
           return remote;
   }
   

Legend:
Removed from v.1.280  
changed lines
  Added in v.1.281