diff options
Diffstat (limited to 'usr.sbin/ntpd/constraint.c')
-rw-r--r-- | usr.sbin/ntpd/constraint.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/usr.sbin/ntpd/constraint.c b/usr.sbin/ntpd/constraint.c index 8f916067e43..4241b70cc83 100644 --- a/usr.sbin/ntpd/constraint.c +++ b/usr.sbin/ntpd/constraint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: constraint.c,v 1.56 2023/12/20 15:36:36 otto Exp $ */ +/* $OpenBSD: constraint.c,v 1.57 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -235,7 +235,6 @@ priv_constraint_msg(u_int32_t id, u_int8_t *data, size_t len, int argc, struct ntp_addr *h; struct constraint *cstr; int pipes[2]; - int rv; if ((cstr = constraint_byid(id)) != NULL) { log_warnx("IMSG_CONSTRAINT_QUERY repeated for id %d", id); @@ -271,15 +270,12 @@ priv_constraint_msg(u_int32_t id, u_int8_t *data, size_t len, int argc, /* Prepare and send constraint data to child. */ cstr->fd = pipes[0]; - imsg_init(&cstr->ibuf, cstr->fd); + imsgbuf_init(&cstr->ibuf, cstr->fd); if (imsg_compose(&cstr->ibuf, IMSG_CONSTRAINT_QUERY, id, 0, -1, data, len) == -1) fatal("%s: imsg_compose", __func__); - do { - rv = imsg_flush(&cstr->ibuf); - } while (rv == -1 && errno == EAGAIN); - if (rv == -1) - fatal("imsg_flush"); + if (imsgbuf_flush(&cstr->ibuf) == -1) + fatal("imsgbuf_flush"); /* * Fork child handlers and make sure to do any sensitive work in the @@ -300,8 +296,9 @@ priv_constraint_readquery(struct constraint *cstr, struct ntp_addr_msg *am, size_t mlen; /* Read the message our parent left us. */ - if (((n = imsg_read(&cstr->ibuf)) == -1 && errno != EAGAIN) || n == 0) - fatal("%s: imsg_read", __func__); + if (((n = imsgbuf_read(&cstr->ibuf)) == -1 && errno != EAGAIN) || + n == 0) + fatal("%s: imsgbuf_read", __func__); if (((n = imsg_get(&cstr->ibuf, &imsg)) == -1) || n == 0) fatal("%s: imsg_get", __func__); if (imsg.hdr.type != IMSG_CONSTRAINT_QUERY) @@ -347,7 +344,7 @@ priv_constraint_child(const char *pw_dir, uid_t pw_uid, gid_t pw_gid) struct sigaction sa; void *ctx; struct iovec iov[2]; - int i, rv; + int i; log_procinit("constraint"); @@ -381,7 +378,7 @@ priv_constraint_child(const char *pw_dir, uid_t pw_uid, gid_t pw_gid) fatal("pledge"); cstr.fd = CONSTRAINT_PASSFD; - imsg_init(&cstr.ibuf, cstr.fd); + imsgbuf_init(&cstr.ibuf, cstr.fd); priv_constraint_readquery(&cstr, &am, &data); /* @@ -436,9 +433,7 @@ priv_constraint_child(const char *pw_dir, uid_t pw_uid, gid_t pw_gid) iov[1].iov_len = sizeof(xmttv); imsg_composev(&cstr.ibuf, IMSG_CONSTRAINT_RESULT, 0, 0, -1, iov, 2); - do { - rv = imsg_flush(&cstr.ibuf); - } while (rv == -1 && errno == EAGAIN); + imsgbuf_flush(&cstr.ibuf); /* Tear down the TLS connection after sending the result */ httpsdate_free(ctx); @@ -618,7 +613,8 @@ priv_constraint_dispatch(struct pollfd *pfd) if (!(pfd->revents & POLLIN)) return (0); - if (((n = imsg_read(&cstr->ibuf)) == -1 && errno != EAGAIN) || n == 0) { + if (((n = imsgbuf_read(&cstr->ibuf)) == -1 && errno != EAGAIN) || + n == 0) { /* there's a race between SIGCHLD delivery and reading imsg but if we've seen the reply, we're good */ priv_constraint_close(pfd->fd, cstr->state != |