From 26df50981fe18b5f244293b203c1a1eb30759554 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Thu, 3 Aug 2023 22:37:34 +0000 Subject: [PATCH] actually use the specified log style --- config.c | 13 ++++++++++++- gmid.c | 2 ++ gmid.h | 1 + server.c | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 6b4accb..e5ce62f 100644 --- a/config.c +++ b/config.c @@ -65,10 +65,11 @@ config_purge(struct conf *conf) struct alist *a, *ta; struct pki *pki, *tpki; struct address *addr, *taddr; - int use_privsep_crypto; + int use_privsep_crypto, log_format; ps = conf->ps; use_privsep_crypto = conf->use_privsep_crypto; + log_format = conf->log_format; free(conf->log_access); free_mime(&conf->mime); @@ -150,6 +151,7 @@ config_purge(struct conf *conf) conf->use_privsep_crypto = use_privsep_crypto; conf->protos = TLS_PROTOCOL_TLSv1_2 | TLS_PROTOCOL_TLSv1_3; conf->log_syslog = 1; + conf->log_format = log_format; init_mime(&conf->mime); TAILQ_INIT(&conf->fcgi); TAILQ_INIT(&conf->hosts); @@ -289,6 +291,10 @@ config_send(struct conf *conf) struct alist *a; size_t i; + if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_LOG_FMT, + &conf->log_format, sizeof(conf->log_format)) == -1) + return -1; + for (i = 0; i < conf->mime.len; ++i) { m = &conf->mime.t[i]; if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_MIME, @@ -528,6 +534,11 @@ config_recv(struct conf *conf, struct imsg *imsg) p = NULL; break; + case IMSG_RECONF_LOG_FMT: + IMSG_SIZE_CHECK(imsg, &conf->log_format); + memcpy(&conf->log_format, imsg->data, datalen); + break; + case IMSG_RECONF_MIME: IMSG_SIZE_CHECK(imsg, &m); memcpy(&m, imsg->data, datalen); diff --git a/gmid.c b/gmid.c index 0929169..658f961 100644 --- a/gmid.c +++ b/gmid.c @@ -126,6 +126,8 @@ log_request(struct client *c, int code, const char *meta) strlcpy(b, t, sizeof(b)); } + log_warnx("log format is %d", conf->log_format); + switch (conf->log_format) { case LOG_FORMAT_LEGACY: ec = asprintf(&fmted, "%s:%s GET %s %d %s", c->rhost, diff --git a/gmid.h b/gmid.h index 16935ca..0ff9f6b 100644 --- a/gmid.h +++ b/gmid.h @@ -334,6 +334,7 @@ enum imsg_type { IMSG_LOG_SYSLOG, IMSG_RECONF_START, + IMSG_RECONF_LOG_FMT, IMSG_RECONF_MIME, IMSG_RECONF_PROTOS, IMSG_RECONF_SOCK, diff --git a/server.c b/server.c index 3bceac6..0fcb49a 100644 --- a/server.c +++ b/server.c @@ -1501,6 +1501,7 @@ server_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) switch (imsg->hdr.type) { case IMSG_RECONF_START: + case IMSG_RECONF_LOG_FMT: case IMSG_RECONF_MIME: case IMSG_RECONF_PROTOS: case IMSG_RECONF_SOCK: