send host addresses to the server process

This commit is contained in:
Omar Polo 2023-06-24 09:14:35 +00:00
parent 9fda962861
commit a0a42860d2
3 changed files with 28 additions and 0 deletions

View File

@ -307,6 +307,7 @@ config_send(struct conf *conf)
TAILQ_FOREACH(h, &conf->hosts, vhosts) {
struct vhost vcopy;
struct address *addr, acopy;
memcpy(&vcopy, h, sizeof(vcopy));
vcopy.cert_path = NULL;
@ -329,6 +330,21 @@ config_send(struct conf *conf)
return -1;
}
TAILQ_FOREACH(addr, &h->addrs, addrs) {
memcpy(&acopy, addr, sizeof(acopy));
memset(&acopy.addrs, 0, sizeof(acopy.addrs));
if (proc_compose(ps, PROC_SERVER,
IMSG_RECONF_HOST_ADDR, &acopy, sizeof(acopy))
== -1)
return -1;
}
if (proc_flush_imsg(ps, PROC_SERVER, -1) == -1) {
log_warn("%s: proc_fush_imsg", __func__);
return -1;
}
TAILQ_FOREACH(l, &h->locations, locations) {
struct location lcopy;
int fd = -1;
@ -598,6 +614,16 @@ config_recv(struct conf *conf, struct imsg *imsg)
h->domain);
break;
case IMSG_RECONF_HOST_ADDR:
log_debug("receiving host addr");
if (h == NULL)
fatalx("recv'd host address withouth host");
IMSG_SIZE_CHECK(imsg, addr);
addr = xcalloc(1, sizeof(*addr));
memcpy(addr, imsg->data, datalen);
TAILQ_INSERT_TAIL(&h->addrs, addr, addrs);
break;
case IMSG_RECONF_LOC:
if (h == NULL)
fatalx("recv'd location without host");

1
gmid.h
View File

@ -346,6 +346,7 @@ enum imsg_type {
IMSG_RECONF_CERT,
IMSG_RECONF_KEY,
IMSG_RECONF_OCSP,
IMSG_RECONF_HOST_ADDR,
IMSG_RECONF_LOC,
IMSG_RECONF_ENV,
IMSG_RECONF_ALIAS,

View File

@ -1518,6 +1518,7 @@ server_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
case IMSG_RECONF_CERT:
case IMSG_RECONF_KEY:
case IMSG_RECONF_OCSP:
case IMSG_RECONF_HOST_ADDR:
case IMSG_RECONF_LOC:
case IMSG_RECONF_ENV:
case IMSG_RECONF_ALIAS: