]> granicus.if.org Git - apache/commitdiff
Allow mod_unique_id to work on systems with no IPv4 address
authorJeff Trawick <trawick@apache.org>
Thu, 25 Apr 2002 18:04:40 +0000 (18:04 +0000)
committerJeff Trawick <trawick@apache.org>
Thu, 25 Apr 2002 18:04:40 +0000 (18:04 +0000)
corresponding to their host name.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94802 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/metadata/mod_unique_id.c

diff --git a/CHANGES b/CHANGES
index b1c3d01eba73b79b73e0cfa4f8d011e1268c2395..6d195b1e54ae35aee07f4ee1b94ab25c6be7b3db 100644 (file)
--- 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.
index a6e2e486fa6c77748e54fa8bcb9467eaceb90de0..8b9eeccbf6181ec32dcc2a70dd5ec144a7a6fd5a 100644 (file)
@@ -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",