[nginx] Fixed handling of UNIX-domain sockets.

Ruslan Ermilov ru at nginx.com
Mon Dec 9 06:17:57 UTC 2013


details:   http://hg.nginx.org/nginx/rev/30e806b8636a
branches:  
changeset: 5464:30e806b8636a
user:      Ruslan Ermilov <ru at nginx.com>
date:      Mon Dec 09 10:16:44 2013 +0400
description:
Fixed handling of UNIX-domain sockets.

When evaluating $local_port, $server_port, and $server_addr,
UNIX-domain sockets were mistakenly interpreted as IPv4 sockets.

diffstat:

 src/core/ngx_connection.c     |   6 ++++++
 src/http/ngx_http_variables.c |  12 ++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diffs (45 lines):

diff -r 1ab1cf63f885 -r 30e806b8636a src/core/ngx_connection.c
--- a/src/core/ngx_connection.c	Mon Dec 09 10:14:51 2013 +0400
+++ b/src/core/ngx_connection.c	Mon Dec 09 10:16:44 2013 +0400
@@ -1095,6 +1095,12 @@ ngx_connection_local_sockaddr(ngx_connec
         break;
 #endif
 
+#if (NGX_HAVE_UNIX_DOMAIN)
+    case AF_UNIX:
+        addr = 1;
+        break;
+#endif
+
     default: /* AF_INET */
         sin = (struct sockaddr_in *) c->local_sockaddr;
         addr = sin->sin_addr.s_addr;
diff -r 1ab1cf63f885 -r 30e806b8636a src/http/ngx_http_variables.c
--- a/src/http/ngx_http_variables.c	Mon Dec 09 10:14:51 2013 +0400
+++ b/src/http/ngx_http_variables.c	Mon Dec 09 10:16:44 2013 +0400
@@ -1185,6 +1185,12 @@ ngx_http_variable_remote_port(ngx_http_r
         break;
 #endif
 
+#if (NGX_HAVE_UNIX_DOMAIN)
+    case AF_UNIX:
+        port = 0;
+        break;
+#endif
+
     default: /* AF_INET */
         sin = (struct sockaddr_in *) r->connection->sockaddr;
         port = ntohs(sin->sin_port);
@@ -1263,6 +1269,12 @@ ngx_http_variable_server_port(ngx_http_r
         break;
 #endif
 
+#if (NGX_HAVE_UNIX_DOMAIN)
+    case AF_UNIX:
+        port = 0;
+        break;
+#endif
+
     default: /* AF_INET */
         sin = (struct sockaddr_in *) r->connection->local_sockaddr;
         port = ntohs(sin->sin_port);



More information about the nginx-devel mailing list