diff options
author | joe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845> | 2010-10-14 15:02:41 +0000 |
---|---|---|
committer | joe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845> | 2010-10-14 15:02:41 +0000 |
commit | 00b3dd9e1bc4e9882c74b42a28285ecc4345a9ff (patch) | |
tree | 068bc4a6e2d5e9beef4bcd18d5a0ab46a8236fd7 | |
parent | 6114355177876452102036651e65279ff169ce43 (diff) | |
download | neon-00b3dd9e1bc4e9882c74b42a28285ecc4345a9ff.tar.gz |
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
git-svn-id: http://svn.webdav.org/repos/projects/neon/branches/0.29.x@1823 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
-rw-r--r-- | macros/neon-test.m4 | 2 | ||||
-rw-r--r-- | test/socket.c | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/macros/neon-test.m4 b/macros/neon-test.m4 index 080c3eb..d1aa930 100644 --- a/macros/neon-test.m4 +++ b/macros/neon-test.m4 @@ -39,7 +39,7 @@ AC_BEFORE([$0], [NEON_XML_PARSER]) 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]) diff --git a/test/socket.c b/test/socket.c index f461a88..3ddf289 100644 --- a/test/socket.c +++ b/test/socket.c @@ -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_compare(void) 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 @@ static int addr_reverse(void) 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); |