commit: r1818 - in neon/trunk: macros test

joe at manyfish.co.uk joe at manyfish.co.uk
Sat Oct 9 11:56:20 EDT 2010


Author: joe
Date: Sat Oct  9 15:56:20 2010
New Revision: 1818

Modified:
   neon/trunk/macros/neon-test.m4
   neon/trunk/test/socket.c

Log:
* 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().


Modified: neon/trunk/macros/neon-test.m4
==============================================================================
--- neon/trunk/macros/neon-test.m4	(original)
+++ neon/trunk/macros/neon-test.m4	Sat Oct  9 15:56:20 2010
@@ -39,7 +39,7 @@
 
 AC_CHECK_HEADERS(sys/time.h stdint.h locale.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/trunk/test/socket.c
==============================================================================
--- neon/trunk/test/socket.c	(original)
+++ neon/trunk/test/socket.c	Sat Oct  9 15:56:20 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"
@@ -370,7 +373,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);
 
@@ -378,7 +389,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