summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2021-08-29 00:37:57 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2021-09-08 15:06:07 -0400
commitad8a27f356a18875de454aebfc8633b386447300 (patch)
treecee7d4b2822beaa58a3fd7028511cc4e00fb472d /src/network.c
parentcd738d4daa0f36f37d1f73c84991c0ccf4433394 (diff)
downloadlighttpd-git-ad8a27f356a18875de454aebfc8633b386447300.tar.gz
[core] cfg server.bindhost after $SERVER["socket"]
init global config for server.bindhost and server.port after initializing $SERVER["socket"] so that if bindhost and port matches another $SERVER["socket"], the $SERVER["socket"] config is used, as the $SERVER["socket"] config inherits from the global scope and can the be overridden. x-ref: "Activate SSL with lighttpd on a Raspberry Pi" https://stackoverflow.com/questions/68939760/activate-ssl-with-lighttpd-on-a-raspberry-pi
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/network.c b/src/network.c
index 58fcb70a..49ceea11 100644
--- a/src/network.c
+++ b/src/network.c
@@ -671,20 +671,12 @@ int network_init(server *srv, int stdin_fd) {
}
}
- /* process srv->srvconf.bindhost
- * (skip if systemd socket activation is enabled and bindhost is empty;
- * do not additionally listen on "*") */
- if (!srv->srvconf.systemd_socket_activation || srv->srvconf.bindhost) {
+ /* special-case srv->srvconf.bindhost = "/dev/stdin" (see server.c) */
+ if (-1 != stdin_fd) {
buffer *b = buffer_init();
- if (srv->srvconf.bindhost)
- buffer_copy_buffer(b, srv->srvconf.bindhost);
- /*(skip adding port if unix socket path)*/
- if (!b->ptr || b->ptr[0] != '/') {
- buffer_append_string_len(b, CONST_STR_LEN(":"));
- buffer_append_int(b, srv->srvconf.port);
- }
-
- rc = (-1 == stdin_fd || 0 == srv->srv_sockets.used)
+ buffer_copy_buffer(b, srv->srvconf.bindhost);
+ /*assert(buffer_eq_slen(b, CONST_STR_LEN("/dev/stdin")));*/
+ rc = (0 == srv->srv_sockets.used)
? network_server_init(srv, &p->defaults, b, 0, stdin_fd)
: close(stdin_fd);/*(graceful restart listening to "/dev/stdin")*/
buffer_free(b);
@@ -725,6 +717,30 @@ int network_init(server *srv, int stdin_fd) {
}
if (0 != rc) break;
+ /* process srv->srvconf.bindhost
+ * init global config for server.bindhost and server.port after
+ * initializing $SERVER["socket"] so that if bindhost and port match
+ * another $SERVER["socket"], the $SERVER["socket"] config is used,
+ * as the $SERVER["socket"] config inherits from the global scope and
+ * can then be overridden. (bindhost = "/dev/stdin" is handled above)
+ * (skip if systemd socket activation is enabled and bindhost is empty;
+ * do not additionally listen on "*") */
+ if ((!srv->srvconf.systemd_socket_activation || srv->srvconf.bindhost)
+ && -1 == stdin_fd) {
+ buffer *b = buffer_init();
+ if (srv->srvconf.bindhost)
+ buffer_copy_buffer(b, srv->srvconf.bindhost);
+ /*(skip adding port if unix socket path)*/
+ if (!b->ptr || b->ptr[0] != '/') {
+ buffer_append_string_len(b, CONST_STR_LEN(":"));
+ buffer_append_int(b, srv->srvconf.port);
+ }
+
+ rc = network_server_init(srv, &p->defaults, b, 0, -1);
+ buffer_free(b);
+ if (0 != rc) break;
+ }
+
if (srv->srvconf.systemd_socket_activation) {
/* activate any inherited sockets not explicitly listed in config */
server_socket *srv_socket;