cvs-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Cvs-cvs] Changes to ccvs/src/server.c


From: Derek Robert Price
Subject: [Cvs-cvs] Changes to ccvs/src/server.c
Date: Sun, 04 Sep 2005 11:25:26 -0400

Index: ccvs/src/server.c
diff -u ccvs/src/server.c:1.437 ccvs/src/server.c:1.438
--- ccvs/src/server.c:1.437     Sun Sep  4 05:16:00 2005
+++ ccvs/src/server.c   Sun Sep  4 15:25:25 2005
@@ -48,8 +48,6 @@
 
 extern char *server_hostname;
 
-# include <netdb.h>
-
 # ifdef HAVE_WINSOCK_H
 #   include <winsock.h>
 # endif
@@ -587,6 +585,9 @@
 
 
 
+/* From GNULIB lib/canon-host.c.  */
+extern char *canon_host (char const *host);
+
 /* Return true if OTHERHOST resolves to this host in the DNS.
  *
  * GLOBALS
@@ -600,7 +601,9 @@
 static inline bool
 isThisHost (const char *otherhost)
 {
-    struct hostent *hinfo;
+    char *fqdno;
+    char *fqdns;
+    bool retval;
 
     /* As an optimization, check the literal strings before looking up
      * OTHERHOST in the DNS.
@@ -608,16 +611,18 @@
     if (!strcasecmp (server_hostname, otherhost))
        return true;
 
-    if (!(hinfo = gethostbyname (otherhost)))
-#ifdef HAVE_HSTRERROR
-       error (1, 0, "Name lookup failed for `%s': %s",
-              otherhost, hstrerror (h_errno));
-#else
-       error (1, 0, "Name lookup failed for `%s': h_error=%d",
-              otherhost, h_errno);
-#endif
+    fqdno = canon_host (otherhost);
+    if (!fqdno)
+       error (1, 0, "Name lookup failed for `%s'", otherhost);
+    fqdns = canon_host (server_hostname);
+    if (!fqdno)
+       error (1, 0, "Name lookup failed for `%s'", server_hostname);
+
+    retval = !strcasecmp (fqdns, fqdno);
 
-    return !strcasecmp (server_hostname, hinfo->h_name);
+    free (fqdno);
+    free (fqdns);
+    return retval;
 }
 
 
@@ -7437,7 +7442,7 @@
 static void
 gserver_authenticate_connection (void)
 {
-    struct hostent *hp;
+    char *hn;
     gss_buffer_desc tok_in, tok_out;
     char buf[1024];
     char *credbuf;
@@ -7448,11 +7453,12 @@
     int nbytes;
     gss_OID mechid;
 
-    hp = gethostbyname (server_hostname);
-    if (hp == NULL)
+    hn = canon_host (server_hostname);
+    if (hn == NULL)
        error (1, 0, "can't get canonical hostname");
 
-    sprintf (buf, "address@hidden", hp->h_name);
+    sprintf (buf, "address@hidden", hn);
+    free (hn);
     tok_in.value = buf;
     tok_in.length = strlen (buf);
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]