From a1416996f1ed3f656c5fea8ff313e4eda9be6bbf Mon Sep 17 00:00:00 2001 From: claudio Date: Wed, 17 Jan 2024 10:01:24 +0000 Subject: [PATCH] Use imsg_get_fd() As usual proc_forward_imsg() is never forwarding a file descriptor so just use -1 there. This should be replaced by imsg_forward(). All other changes are simple conversions. OK tb@ --- usr.sbin/relayd/agentx_control.c | 10 ++++++---- usr.sbin/relayd/config.c | 14 +++++++------- usr.sbin/relayd/proc.c | 6 +++--- usr.sbin/relayd/relay.c | 4 ++-- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/usr.sbin/relayd/agentx_control.c b/usr.sbin/relayd/agentx_control.c index 113ae0482fc..b5f75f20ce6 100644 --- a/usr.sbin/relayd/agentx_control.c +++ b/usr.sbin/relayd/agentx_control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agentx_control.c,v 1.6 2022/08/31 16:17:18 dv Exp $ */ +/* $OpenBSD: agentx_control.c,v 1.7 2024/01/17 10:01:24 claudio Exp $ */ /* * Copyright (c) 2020 Martijn van Duren @@ -462,16 +462,18 @@ void agentx_getsock(struct imsg *imsg) { struct timeval tv = AGENTX_RECONNECT_TIMEOUT; + int fd; - if (imsg->fd == -1) + fd = imsg_get_fd(imsg); + if (fd == -1) goto retry; event_del(&(env->sc_agentxev)); - event_set(&(env->sc_agentxev), imsg->fd, EV_READ | EV_PERSIST, + event_set(&(env->sc_agentxev), fd, EV_READ | EV_PERSIST, agentx_sock, env); event_add(&(env->sc_agentxev), NULL); - agentx_connect(sa, imsg->fd); + agentx_connect(sa, fd); retry: evtimer_set(&env->sc_agentxev, agentx_sock, env); diff --git a/usr.sbin/relayd/config.c b/usr.sbin/relayd/config.c index b8f91bb7ad1..3024c0768f0 100644 --- a/usr.sbin/relayd/config.c +++ b/usr.sbin/relayd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.44 2023/06/25 08:07:38 op Exp $ */ +/* $OpenBSD: config.c,v 1.45 2024/01/17 10:01:24 claudio Exp $ */ /* * Copyright (c) 2011 - 2014 Reyk Floeter @@ -1030,7 +1030,7 @@ config_getrelay(struct relayd *env, struct imsg *imsg) memcpy(&rlay->rl_conf, p, sizeof(rlay->rl_conf)); s = sizeof(rlay->rl_conf); - rlay->rl_s = imsg->fd; + rlay->rl_s = imsg_get_fd(imsg); rlay->rl_tls_ca_fd = -1; rlay->rl_tls_cacert_fd = -1; @@ -1148,19 +1148,19 @@ config_getrelayfd(struct relayd *env, struct imsg *imsg) switch (crfd.type) { case RELAY_FD_CERT: - cert->cert_fd = imsg->fd; + cert->cert_fd = imsg_get_fd(imsg); break; case RELAY_FD_KEY: - cert->cert_key_fd = imsg->fd; + cert->cert_key_fd = imsg_get_fd(imsg); break; case RELAY_FD_OCSP: - cert->cert_ocsp_fd = imsg->fd; + cert->cert_ocsp_fd = imsg_get_fd(imsg); break; case RELAY_FD_CACERT: - rlay->rl_tls_ca_fd = imsg->fd; + rlay->rl_tls_ca_fd = imsg_get_fd(imsg); break; case RELAY_FD_CAFILE: - rlay->rl_tls_cacert_fd = imsg->fd; + rlay->rl_tls_cacert_fd = imsg_get_fd(imsg); break; } diff --git a/usr.sbin/relayd/proc.c b/usr.sbin/relayd/proc.c index 52d27d25df4..1da7e585fc4 100644 --- a/usr.sbin/relayd/proc.c +++ b/usr.sbin/relayd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.44 2023/02/15 20:44:01 tobhe Exp $ */ +/* $OpenBSD: proc.c,v 1.45 2024/01/17 10:01:24 claudio Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter @@ -655,7 +655,7 @@ proc_dispatch(int fd, short event, void *arg) case IMSG_CTL_PROCFD: IMSG_SIZE_CHECK(&imsg, &pf); memcpy(&pf, imsg.data, sizeof(pf)); - proc_accept(ps, imsg.fd, pf.pf_procid, + proc_accept(ps, imsg_get_fd(&imsg), pf.pf_procid, pf.pf_instance); break; default: @@ -786,7 +786,7 @@ proc_forward_imsg(struct privsep *ps, struct imsg *imsg, enum privsep_procid id, int n) { return (proc_compose_imsg(ps, id, n, imsg->hdr.type, - imsg->hdr.peerid, imsg->fd, imsg->data, IMSG_DATA_SIZE(imsg))); + imsg->hdr.peerid, -1, imsg->data, IMSG_DATA_SIZE(imsg))); } struct imsgbuf * diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 5d3f38c5bd5..c29f3917152 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.258 2023/10/29 11:27:11 kn Exp $ */ +/* $OpenBSD: relay.c,v 1.259 2024/01/17 10:01:24 claudio Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -1993,7 +1993,7 @@ relay_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) } /* Will validate the result later */ - con->se_bnds = imsg->fd; + con->se_bnds = imsg_get_fd(imsg); evtimer_del(&con->se_ev); evtimer_set(&con->se_ev, relay_bindany, con); -- 2.20.1