diff options
author | Omar Polo <op@omarpolo.com> | 2023-06-12 21:27:24 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2023-06-12 21:27:24 +0000 |
commit | 2cef5cf42a98f8b9c8c4f1a4d4da40b389de770a (patch) | |
tree | b6b03671062692434a9d0d6bb1f2b9756b5f4bb0 /config.c | |
parent | 89cfcb456921ed65a812b6e960de390553ac0ae5 (diff) |
load_ca: get a buffer instead of a fd
We dup(1) the ca fd and send it to various processes, so they fail
loading it. Instead, use load_file to get a buffer with the file
content and pass that to load_ca which then loads via BIO.
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -549,7 +549,8 @@ config_recv(struct conf *conf, struct imsg *imsg) struct envlist *env; struct alist *alias; struct proxy *proxy; - size_t datalen; + uint8_t *d; + size_t len, datalen; datalen = IMSG_DATA_SIZE(imsg); @@ -672,9 +673,12 @@ config_recv(struct conf *conf, struct imsg *imsg) memcpy(loc, imsg->data, datalen); if (imsg->fd != -1) { - loc->reqca = load_ca(imsg->fd); + if (load_file(imsg->fd, &d, &len) == -1) + fatal("load_file"); + loc->reqca = load_ca(d, len); if (loc->reqca == NULL) fatalx("failed to load CA"); + free(d); } TAILQ_INSERT_TAIL(&h->locations, loc, locations); @@ -707,9 +711,12 @@ config_recv(struct conf *conf, struct imsg *imsg) memcpy(proxy, imsg->data, datalen); if (imsg->fd != -1) { - proxy->reqca = load_ca(imsg->fd); + if (load_file(imsg->fd, &d, &len) == -1) + fatal("load_file"); + proxy->reqca = load_ca(d, len); if (proxy->reqca == NULL) fatal("failed to load CA"); + free(d); } TAILQ_INSERT_TAIL(&h->proxies, proxy, proxies); |