[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.104 and 1.105

version 1.104, 2001/04/12 19:15:25 version 1.105, 2001/04/30 11:18:52
Line 147 
Line 147 
 int  int
 ssh_create_socket(struct passwd *pw, int privileged, int family)  ssh_create_socket(struct passwd *pw, int privileged, int family)
 {  {
         int sock;          int sock, gaierr;
           struct addrinfo hints, *res;
   
         /*          /*
          * If we are running as root and want to connect to a privileged           * If we are running as root and want to connect to a privileged
Line 160 
Line 161 
                         error("rresvport: af=%d %.100s", family, strerror(errno));                          error("rresvport: af=%d %.100s", family, strerror(errno));
                 else                  else
                         debug("Allocated local port %d.", p);                          debug("Allocated local port %d.", p);
         } else {                  return sock;
                 /*  
                  * Just create an ordinary socket on arbitrary port.  We use  
                  * the user's uid to create the socket.  
                  */  
                 temporarily_use_uid(pw);  
                 sock = socket(family, SOCK_STREAM, 0);  
                 if (sock < 0)  
                         error("socket: %.100s", strerror(errno));  
                 restore_uid();  
         }          }
           /*
            * Just create an ordinary socket on arbitrary port.  We use
            * the user's uid to create the socket.
            */
           temporarily_use_uid(pw);
           sock = socket(family, SOCK_STREAM, 0);
           if (sock < 0)
                   error("socket: %.100s", strerror(errno));
           restore_uid();
   
           /* Bind the socket to an alternative local IP address */
           if (options.bind_address == NULL)
                   return sock;
   
           memset(&hints, 0, sizeof(hints));
           hints.ai_family = IPv4or6;
           hints.ai_socktype = SOCK_STREAM;
           hints.ai_flags = AI_PASSIVE;
           gaierr = getaddrinfo(options.bind_address, "0", &hints, &res);
           if (gaierr) {
                   error("getaddrinfo: %s: %s", options.bind_address,
                       gai_strerror(gaierr));
                   close(sock);
                   return -1;
           }
           if (bind(sock, res->ai_addr, res->ai_addrlen) < 0) {
                   error("bind: %s: %s", options.bind_address, strerror(errno));
                   close(sock);
                   freeaddrinfo(res);
                   return -1;
           }
           freeaddrinfo(res);
         return sock;          return sock;
 }  }
   

Legend:
Removed from v.1.104  
changed lines
  Added in v.1.105