]> andersk Git - gssapi-openssh.git/commitdiff
use gethostbyaddr() to query the resolver for the official hostname
authorjbasney <jbasney>
Mon, 9 Sep 2002 22:01:52 +0000 (22:01 +0000)
committerjbasney <jbasney>
Mon, 9 Sep 2002 22:01:52 +0000 (22:01 +0000)
of the target host

openssh/gss-genr.c
openssh/sshconnect1.c

index 5dbd8b50ac09935f3198426a00bf17d4fe1ba47f..a21d69776339c6fe5d96fd1252a80d82262a7f8c 100644 (file)
@@ -425,7 +425,7 @@ ssh_gssapi_import_name(Gssctxt *ctx, const char *host) {
        gss_buffer_desc gssbuf;
        OM_uint32 maj_status, min_status;
        struct hostent *hostinfo = NULL;
-       char *xhost;
+       char *xhost, *addr;
        
        /* Make a copy of the host name, in case it was returned by a
         * previous call to gethostbyname(). */ 
@@ -439,8 +439,16 @@ ssh_gssapi_import_name(Gssctxt *ctx, const char *host) {
        if ((hostinfo == NULL) || (hostinfo->h_name == NULL)) {
                debug("Unable to get FQDN for \"%s\"", xhost);
        } else {
-               xfree(xhost);
-               xhost = xstrdup(hostinfo->h_name);
+               addr = xmalloc(hostinfo->h_length);
+               memcpy(addr, hostinfo->h_addr, hostinfo->h_length);
+               hostinfo = gethostbyaddr(addr, hostinfo->h_length, AF_INET);
+               xfree(addr);
+               if ((hostinfo == NULL) || (hostinfo->h_name == NULL)) {
+                   debug("Unable to get FQDN for \"%s\"", xhost);
+               } else {
+                   xfree(xhost);
+                   xhost = xstrdup(hostinfo->h_name);
+               }
        }
                
         gssbuf.length = sizeof("host@")+strlen(xhost);
index f69a72ca61a66988ca640e02f6509c953af95c94..6dd4cb72dd41ab36aeaebb4e99c5ec6687337ff5 100644 (file)
@@ -1086,13 +1086,23 @@ int try_gssapi_authentication(char *host, Options *options)
   int type;
   char *gssapi_auth_type = NULL;
   struct hostent *hostinfo;
-
+  char *addr;
 
   /*
    * host is not guarenteed to be a FQDN, so we need to make sure it is.
    */
   hostinfo = gethostbyname(host);
 
+  if ((hostinfo == NULL) || (hostinfo->h_addr == NULL)) {
+      debug("GSSAPI authentication: Unable to get FQDN for \"%s\"", host);
+      goto cleanup;
+  }
+
+  addr = xmalloc(hostinfo->h_length);
+  memcpy(addr, hostinfo->h_addr, hostinfo->h_length);
+  hostinfo = gethostbyaddr(addr, hostinfo->h_length, AF_INET);
+  xfree(addr);
+
   if ((hostinfo == NULL) || (hostinfo->h_name == NULL)) {
       debug("GSSAPI authentication: Unable to get FQDN for \"%s\"", host);
       goto cleanup;
This page took 0.063676 seconds and 5 git commands to generate.