e363175e30
- refresh upstream patch for 68421
119 lines
3.6 KiB
Diff
119 lines
3.6 KiB
Diff
From 5112fdd670175f4eab4529c84ccf4774f5577797 Mon Sep 17 00:00:00 2001
|
|
From: Remi Collet <remi@php.net>
|
|
Date: Fri, 14 Nov 2014 19:09:50 +0100
|
|
Subject: [PATCH] Fix bug #68421 access.format='%R' doesn't log ipv6 address
|
|
|
|
---
|
|
sapi/fpm/fpm/fastcgi.c | 10 ++++++++--
|
|
sapi/fpm/fpm/fastcgi.h | 2 +-
|
|
sapi/fpm/fpm/fpm_log.c | 2 +-
|
|
3 files changed, 10 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c
|
|
index d77b6f8..86fca17 100644
|
|
--- a/sapi/fpm/fpm/fastcgi.c
|
|
+++ b/sapi/fpm/fpm/fastcgi.c
|
|
@@ -137,6 +137,7 @@ typedef union _sa_t {
|
|
struct sockaddr sa;
|
|
struct sockaddr_un sa_unix;
|
|
struct sockaddr_in sa_inet;
|
|
+ struct sockaddr_in6 sa_inet6;
|
|
} sa_t;
|
|
|
|
static HashTable fcgi_mgmt_vars;
|
|
@@ -1094,12 +1095,17 @@ void fcgi_free_mgmt_var_cb(void * ptr)
|
|
pefree(*var, 1);
|
|
}
|
|
|
|
-char *fcgi_get_last_client_ip() /* {{{ */
|
|
+const char *fcgi_get_last_client_ip() /* {{{ */
|
|
{
|
|
+ static char str[INET6_ADDRSTRLEN];
|
|
+
|
|
if (client_sa.sa.sa_family == AF_UNIX) {
|
|
return NULL;
|
|
}
|
|
- return inet_ntoa(client_sa.sa_inet.sin_addr);
|
|
+ if (client_sa.sa.sa_family == AF_INET) {
|
|
+ return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet.sin_addr, str, INET6_ADDRSTRLEN);
|
|
+ }
|
|
+ return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet6.sin6_addr, str, INET6_ADDRSTRLEN);
|
|
}
|
|
/* }}} */
|
|
/*
|
|
diff --git a/sapi/fpm/fpm/fastcgi.h b/sapi/fpm/fpm/fastcgi.h
|
|
index 34f9eef..f5cfe9f 100644
|
|
--- a/sapi/fpm/fpm/fastcgi.h
|
|
+++ b/sapi/fpm/fpm/fastcgi.h
|
|
@@ -133,7 +133,7 @@ int fcgi_flush(fcgi_request *req, int close);
|
|
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
|
|
void fcgi_free_mgmt_var_cb(void * ptr);
|
|
|
|
-char *fcgi_get_last_client_ip();
|
|
+const char *fcgi_get_last_client_ip();
|
|
|
|
/*
|
|
* Local variables:
|
|
diff --git a/sapi/fpm/fpm/fpm_log.c b/sapi/fpm/fpm/fpm_log.c
|
|
index 4e1a057..c71281b 100644
|
|
--- a/sapi/fpm/fpm/fpm_log.c
|
|
+++ b/sapi/fpm/fpm/fpm_log.c
|
|
@@ -367,7 +367,7 @@ int fpm_log_write(char *log_format TSRMLS_DC) /* {{{ */
|
|
|
|
case 'R': /* remote IP address */
|
|
if (!test) {
|
|
- char *tmp = fcgi_get_last_client_ip();
|
|
+ const char *tmp = fcgi_get_last_client_ip();
|
|
len2 = snprintf(b, FPM_LOG_BUFFER - len, "%s", tmp ? tmp : "-");
|
|
}
|
|
break;
|
|
--
|
|
2.1.0
|
|
|
|
From 4657289e87e18bb8967d5a8b0163c772d410e2b8 Mon Sep 17 00:00:00 2001
|
|
From: Remi Collet <remi@php.net>
|
|
Date: Mon, 17 Nov 2014 06:53:38 +0100
|
|
Subject: [PATCH] Improve fix bug #68421 access.format='%R' doesn't log ipv6
|
|
address
|
|
|
|
Log IPv4-Mapped-Ipv6 address as IPv4 (not as IPv6)
|
|
---
|
|
sapi/fpm/fpm/fastcgi.c | 18 ++++++++++++++----
|
|
1 file changed, 14 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c
|
|
index 86fca17..d1db0ec 100644
|
|
--- a/sapi/fpm/fpm/fastcgi.c
|
|
+++ b/sapi/fpm/fpm/fastcgi.c
|
|
@@ -1099,13 +1099,23 @@ const char *fcgi_get_last_client_ip() /* {{{ */
|
|
{
|
|
static char str[INET6_ADDRSTRLEN];
|
|
|
|
- if (client_sa.sa.sa_family == AF_UNIX) {
|
|
- return NULL;
|
|
- }
|
|
+ /* Ipv4 */
|
|
if (client_sa.sa.sa_family == AF_INET) {
|
|
return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet.sin_addr, str, INET6_ADDRSTRLEN);
|
|
}
|
|
- return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet6.sin6_addr, str, INET6_ADDRSTRLEN);
|
|
+#ifdef IN6_IS_ADDR_V4MAPPED
|
|
+ /* Ipv4-Mapped-Ipv6 */
|
|
+ if (client_sa.sa.sa_family == AF_INET6
|
|
+ && IN6_IS_ADDR_V4MAPPED(&client_sa.sa_inet6.sin6_addr)) {
|
|
+ return inet_ntop(AF_INET, ((char *)&client_sa.sa_inet6.sin6_addr)+12, str, INET6_ADDRSTRLEN);
|
|
+ }
|
|
+#endif
|
|
+ /* Ipv6 */
|
|
+ if (client_sa.sa.sa_family == AF_INET6) {
|
|
+ return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet6.sin6_addr, str, INET6_ADDRSTRLEN);
|
|
+ }
|
|
+ /* Unix socket */
|
|
+ return NULL;
|
|
}
|
|
/* }}} */
|
|
/*
|
|
--
|
|
2.1.0
|
|
|