summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-10-27 22:16:00 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-10-28 22:58:12 -0400
commitf394207d5f39b2c0403bae6567cc61d257c04ffc (patch)
tree307a6f8d199277df3b4dd3aa9b1e6be1d8823554
parentb27f1c0910379e8be7e23818d2dbdeb650a7d743 (diff)
downloadlighttpd1.4-f394207d5f39b2c0403bae6567cc61d257c04ffc.tar.gz
lighttpd1.4-f394207d5f39b2c0403bae6567cc61d257c04ffc.zip
[core] fix implicit wildcard IPv4 and IPv6 listen
fix implicit wildcard IPv4 and IPv6 listening (regression in 1.4.46) (broken in commit:5248b46c) workaround (without this patch): server.set-v6only = "disable" (which may produce a warning when lighttpd parses config) x-ref: https://redmine.lighttpd.net/boards/2/topics/7720
-rw-r--r--src/network.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/network.c b/src/network.c
index 39ebfbf3..6b92ae07 100644
--- a/src/network.c
+++ b/src/network.c
@@ -146,6 +146,7 @@ static int network_server_init(server *srv, buffer *host_token, size_t sidx, int
specific_config *s = srv->config_storage[sidx];
socklen_t addr_len = sizeof(sock_addr);
sock_addr addr;
+ int set_v6only = 0;
#ifdef __WIN32
int err;
@@ -197,6 +198,17 @@ static int network_server_init(server *srv, buffer *host_token, size_t sidx, int
} else if (0 != network_host_parse_addr(srv, &addr, &addr_len, host_token, s->use_ipv6)) {
return -1;
}
+
+ #ifdef HAVE_IPV6
+ if (*host != '\0' && AF_INET6 == addr.plain.sa_family) {
+ if (s->set_v6only) {
+ set_v6only = 1;
+ } else {
+ log_error_write(srv, __FILE__, __LINE__, "s", "warning: server.set-v6only will be removed soon, update your config to have different sockets for ipv4 and ipv6");
+ }
+ }
+ #endif
+
network_host_normalize_addr_str(host_token, &addr);
host = host_token->ptr;
@@ -286,17 +298,12 @@ static int network_server_init(server *srv, buffer *host_token, size_t sidx, int
}
#ifdef HAVE_IPV6
- if (AF_INET6 == srv_socket->addr.plain.sa_family
- && host != NULL) {
- if (s->set_v6only) {
+ if (set_v6only && -1 == stdin_fd) {
int val = 1;
if (-1 == setsockopt(srv_socket->fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "setsockopt(IPV6_V6ONLY) failed:", strerror(errno));
return -1;
}
- } else {
- log_error_write(srv, __FILE__, __LINE__, "s", "warning: server.set-v6only will be removed soon, update your config to have different sockets for ipv4 and ipv6");
- }
}
#endif