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

Diff for /src/usr.bin/ssh/canohost.c between version 1.44.2.2 and 1.45

version 1.44.2.2, 2006/10/06 03:19:32 version 1.45, 2005/10/03 07:44:42
Line 1 
Line 1 
 /* $OpenBSD$ */  
 /*  /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>   * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland   * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
Line 12 
Line 11 
  * called by a name other than "ssh" or "Secure Shell".   * called by a name other than "ssh" or "Secure Shell".
  */   */
   
 #include <sys/types.h>  #include "includes.h"
 #include <sys/socket.h>  RCSID("$OpenBSD$");
   
 #include <netinet/in.h>  
   
 #include <ctype.h>  
 #include <errno.h>  
 #include <netdb.h>  
 #include <stdio.h>  
 #include <stdlib.h>  
 #include <string.h>  
 #include <stdarg.h>  
   
 #include "xmalloc.h"  
 #include "packet.h"  #include "packet.h"
   #include "xmalloc.h"
 #include "log.h"  #include "log.h"
 #include "canohost.h"  #include "canohost.h"
   
Line 93 
Line 82 
          */           */
         for (i = 0; name[i]; i++)          for (i = 0; name[i]; i++)
                 if (isupper(name[i]))                  if (isupper(name[i]))
                         name[i] = (char)tolower(name[i]);                          name[i] = tolower(name[i]);
         /*          /*
          * Map it back to an IP address and check that the given           * Map it back to an IP address and check that the given
          * address actually is an address of this host.  This is           * address actually is an address of this host.  This is
Line 108 
Line 97 
         hints.ai_socktype = SOCK_STREAM;          hints.ai_socktype = SOCK_STREAM;
         if (getaddrinfo(name, NULL, &hints, &aitop) != 0) {          if (getaddrinfo(name, NULL, &hints, &aitop) != 0) {
                 logit("reverse mapping checking getaddrinfo for %.700s "                  logit("reverse mapping checking getaddrinfo for %.700s "
                     "[%s] failed - POSSIBLE BREAK-IN ATTEMPT!", name, ntop);                      "failed - POSSIBLE BREAKIN ATTEMPT!", name);
                 return xstrdup(ntop);                  return xstrdup(ntop);
         }          }
         /* Look for the address from the list of addresses. */          /* Look for the address from the list of addresses. */
Line 123 
Line 112 
         if (!ai) {          if (!ai) {
                 /* Address not found for the host name. */                  /* Address not found for the host name. */
                 logit("Address %.100s maps to %.600s, but this does not "                  logit("Address %.100s maps to %.600s, but this does not "
                     "map back to the address - POSSIBLE BREAK-IN ATTEMPT!",                      "map back to the address - POSSIBLE BREAKIN ATTEMPT!",
                     ntop, name);                      ntop, name);
                 return xstrdup(ntop);                  return xstrdup(ntop);
         }          }
Line 163 
Line 152 
                 for (i = 0; i < option_size; i++)                  for (i = 0; i < option_size; i++)
                         snprintf(text + i*3, sizeof(text) - i*3,                          snprintf(text + i*3, sizeof(text) - i*3,
                             " %2.2x", options[i]);                              " %2.2x", options[i]);
                 fatal("Connection from %.100s with IP options:%.800s",                  logit("Connection from %.100s with IP options:%.800s",
                     ipaddr, text);                      ipaddr, text);
                   packet_disconnect("Connection from %.100s with IP options:%.800s",
                       ipaddr, text);
         }          }
 }  }
   
Line 177 
Line 168 
 const char *  const char *
 get_canonical_hostname(int use_dns)  get_canonical_hostname(int use_dns)
 {  {
         char *host;  
         static char *canonical_host_name = NULL;          static char *canonical_host_name = NULL;
         static char *remote_ip = NULL;          static int use_dns_done = 0;
   
         /* Check if we have previously retrieved name with same option. */          /* Check if we have previously retrieved name with same option. */
         if (use_dns && canonical_host_name != NULL)          if (canonical_host_name != NULL) {
                 return canonical_host_name;                  if (use_dns_done != use_dns)
         if (!use_dns && remote_ip != NULL)                          xfree(canonical_host_name);
                 return remote_ip;                  else
                           return canonical_host_name;
           }
   
         /* Get the real hostname if socket; otherwise return UNKNOWN. */          /* Get the real hostname if socket; otherwise return UNKNOWN. */
         if (packet_connection_is_on_socket())          if (packet_connection_is_on_socket())
                 host = get_remote_hostname(packet_get_connection_in(), use_dns);                  canonical_host_name = get_remote_hostname(
                       packet_get_connection_in(), use_dns);
         else          else
                 host = "UNKNOWN";                  canonical_host_name = xstrdup("UNKNOWN");
   
         if (use_dns)          use_dns_done = use_dns;
                 canonical_host_name = host;          return canonical_host_name;
         else  
                 remote_ip = host;  
         return host;  
 }  }
   
 /*  /*

Legend:
Removed from v.1.44.2.2  
changed lines
  Added in v.1.45