commit: r1823 - in neon/branches/0.29.x: macros test

joe at manyfish.co.uk joe at manyfish.co.uk
Thu Oct 14 11:02:41 EDT 2010


Author: joe
Date: Thu Oct 14 15:02:41 2010
New Revision: 1823

Modified:
   neon/branches/0.29.x/macros/neon-test.m4
   neon/branches/0.29.x/test/socket.c

Log:
Merge r1818 from trunk:

* test/socket.c (addr_reverse) [HAVE_GETHOSTNAME]: Accept system
  hostname as reverse of 127.0.0.1.

* macros/neon-test.m4 (NEON_TEST): Check for gethostname().

Submitted by: joe
Reviewed by: jorton


Modified: neon/branches/0.29.x/macros/neon-test.m4
==============================================================================
--- neon/branches/0.29.x/macros/neon-test.m4	(original)
+++ neon/branches/0.29.x/macros/neon-test.m4	Thu Oct 14 15:02:41 2010
@@ -39,7 +39,7 @@
 
 AC_CHECK_HEADERS(sys/time.h stdint.h locale.h signal.h)
 
-AC_CHECK_FUNCS(pipe isatty usleep shutdown setlocale)
+AC_CHECK_FUNCS(pipe isatty usleep shutdown setlocale gethostname)
 
 AC_REQUIRE([NE_FIND_AR])
 

Modified: neon/branches/0.29.x/test/socket.c
==============================================================================
--- neon/branches/0.29.x/test/socket.c	(original)
+++ neon/branches/0.29.x/test/socket.c	Thu Oct 14 15:02:41 2010
@@ -32,6 +32,9 @@
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* for gethostname() */
+#endif
 #include <time.h> /* for time() */
 
 #include "ne_socket.h"
@@ -368,7 +371,15 @@
 static int addr_reverse(void)
 {
     ne_inet_addr *ia = ne_iaddr_make(ne_iaddr_ipv4, raw_127);
-    char buf[128];
+    char buf[128], *syshost = NULL;
+
+#ifdef HAVE_GETHOSTNAME
+    char host[128];
+
+    if (gethostname(host, sizeof host) == 0) {
+        syshost = host;
+    }
+#endif
 
     ONN("ne_iaddr_make returned NULL", ia == NULL);
 
@@ -376,7 +387,8 @@
         ne_iaddr_reverse(ia, buf, sizeof buf) != 0);
 
     ONV(!(strcmp(buf, "localhost.localdomain") == 0
-          || strcmp(buf, "localhost") == 0),
+          || strcmp(buf, "localhost") == 0
+          || (syshost && strcmp(buf, syshost) == 0)),
         ("reverse lookup for 127.0.0.1 got %s", buf));
 
     ne_iaddr_free(ia);



More information about the neon-commits mailing list