From 42f4dbfaefe4abe5f89504c49107b5134486767c Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Thu, 25 Apr 2002 18:04:40 +0000 Subject: [PATCH] Allow mod_unique_id to work on systems with no IPv4 address corresponding to their host name. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94802 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ modules/metadata/mod_unique_id.c | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index b1c3d01eba..6d195b1e54 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.37 + *) Allow mod_unique_id to work on systems with no IPv4 address + corresponding to their host name. [Jeff Trawick] + Changes with Apache 2.0.36 *) Fix suexec behavior with user directories. PR 7810. diff --git a/modules/metadata/mod_unique_id.c b/modules/metadata/mod_unique_id.c index a6e2e486fa..8b9eeccbf6 100644 --- a/modules/metadata/mod_unique_id.c +++ b/modules/metadata/mod_unique_id.c @@ -213,17 +213,26 @@ static int unique_id_global_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pt return HTTP_INTERNAL_SERVER_ERROR; } - /* XXX theoretically there are boxes out there which want to use - * mod_unique_id but which have no IPv4 address... send in a patch :) - */ - if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) != APR_SUCCESS) { + if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) == APR_SUCCESS) { + global_in_addr = sockaddr->sa.sin.sin_addr.s_addr; + } + else { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server, "mod_unique_id: unable to find IPv4 address of \"%s\"", str); +#if APR_HAVE_IPV6 + if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET6, 0, 0, p)) == APR_SUCCESS) { + memcpy(&global_in_addr, + sockaddr->ipaddr_ptr + sockaddr->ipaddr_len - sizeof(global_in_addr), + sizeof(global_in_addr)); + ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server, + "mod_unique_id: using low-order bits of IPv6 address " + "as if they were unique"); + } + else +#endif return HTTP_INTERNAL_SERVER_ERROR; } - global_in_addr = sockaddr->sa.sin.sin_addr.s_addr; - apr_sockaddr_ip_get(&ipaddrstr, sockaddr); ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, main_server, "mod_unique_id: using ip addr %s", -- 2.50.1