Skip to content

Commit 42f4dbf

Browse files
committed
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
1 parent 782d754 commit 42f4dbf

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Changes with Apache 2.0.37
22

3+
*) Allow mod_unique_id to work on systems with no IPv4 address
4+
corresponding to their host name. [Jeff Trawick]
5+
36
Changes with Apache 2.0.36
47

58
*) Fix suexec behavior with user directories. PR 7810.

modules/metadata/mod_unique_id.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,26 @@ static int unique_id_global_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pt
213213
return HTTP_INTERNAL_SERVER_ERROR;
214214
}
215215

216-
/* XXX theoretically there are boxes out there which want to use
217-
* mod_unique_id but which have no IPv4 address... send in a patch :)
218-
*/
219-
if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) != APR_SUCCESS) {
216+
if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) == APR_SUCCESS) {
217+
global_in_addr = sockaddr->sa.sin.sin_addr.s_addr;
218+
}
219+
else {
220220
ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server,
221221
"mod_unique_id: unable to find IPv4 address of \"%s\"", str);
222+
#if APR_HAVE_IPV6
223+
if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET6, 0, 0, p)) == APR_SUCCESS) {
224+
memcpy(&global_in_addr,
225+
sockaddr->ipaddr_ptr + sockaddr->ipaddr_len - sizeof(global_in_addr),
226+
sizeof(global_in_addr));
227+
ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server,
228+
"mod_unique_id: using low-order bits of IPv6 address "
229+
"as if they were unique");
230+
}
231+
else
232+
#endif
222233
return HTTP_INTERNAL_SERVER_ERROR;
223234
}
224235

225-
global_in_addr = sockaddr->sa.sin.sin_addr.s_addr;
226-
227236
apr_sockaddr_ip_get(&ipaddrstr, sockaddr);
228237
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, main_server,
229238
"mod_unique_id: using ip addr %s",

0 commit comments

Comments
 (0)