1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-22 16:42:56 -08:00

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@
This commit is contained in:
claudio 2024-01-17 10:01:24 +00:00
parent 135f245e41
commit a1416996f1
4 changed files with 18 additions and 16 deletions

View File

@ -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 <martijn@openbsd.org> * Copyright (c) 2020 Martijn van Duren <martijn@openbsd.org>
@ -462,16 +462,18 @@ void
agentx_getsock(struct imsg *imsg) agentx_getsock(struct imsg *imsg)
{ {
struct timeval tv = AGENTX_RECONNECT_TIMEOUT; struct timeval tv = AGENTX_RECONNECT_TIMEOUT;
int fd;
if (imsg->fd == -1) fd = imsg_get_fd(imsg);
if (fd == -1)
goto retry; goto retry;
event_del(&(env->sc_agentxev)); 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); agentx_sock, env);
event_add(&(env->sc_agentxev), NULL); event_add(&(env->sc_agentxev), NULL);
agentx_connect(sa, imsg->fd); agentx_connect(sa, fd);
retry: retry:
evtimer_set(&env->sc_agentxev, agentx_sock, env); evtimer_set(&env->sc_agentxev, agentx_sock, env);

View File

@ -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 <reyk@openbsd.org> * Copyright (c) 2011 - 2014 Reyk Floeter <reyk@openbsd.org>
@ -1030,7 +1030,7 @@ config_getrelay(struct relayd *env, struct imsg *imsg)
memcpy(&rlay->rl_conf, p, sizeof(rlay->rl_conf)); memcpy(&rlay->rl_conf, p, sizeof(rlay->rl_conf));
s = 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_ca_fd = -1;
rlay->rl_tls_cacert_fd = -1; rlay->rl_tls_cacert_fd = -1;
@ -1148,19 +1148,19 @@ config_getrelayfd(struct relayd *env, struct imsg *imsg)
switch (crfd.type) { switch (crfd.type) {
case RELAY_FD_CERT: case RELAY_FD_CERT:
cert->cert_fd = imsg->fd; cert->cert_fd = imsg_get_fd(imsg);
break; break;
case RELAY_FD_KEY: case RELAY_FD_KEY:
cert->cert_key_fd = imsg->fd; cert->cert_key_fd = imsg_get_fd(imsg);
break; break;
case RELAY_FD_OCSP: case RELAY_FD_OCSP:
cert->cert_ocsp_fd = imsg->fd; cert->cert_ocsp_fd = imsg_get_fd(imsg);
break; break;
case RELAY_FD_CACERT: case RELAY_FD_CACERT:
rlay->rl_tls_ca_fd = imsg->fd; rlay->rl_tls_ca_fd = imsg_get_fd(imsg);
break; break;
case RELAY_FD_CAFILE: case RELAY_FD_CAFILE:
rlay->rl_tls_cacert_fd = imsg->fd; rlay->rl_tls_cacert_fd = imsg_get_fd(imsg);
break; break;
} }

View File

@ -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 <reyk@openbsd.org> * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@ -655,7 +655,7 @@ proc_dispatch(int fd, short event, void *arg)
case IMSG_CTL_PROCFD: case IMSG_CTL_PROCFD:
IMSG_SIZE_CHECK(&imsg, &pf); IMSG_SIZE_CHECK(&imsg, &pf);
memcpy(&pf, imsg.data, sizeof(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); pf.pf_instance);
break; break;
default: default:
@ -786,7 +786,7 @@ proc_forward_imsg(struct privsep *ps, struct imsg *imsg,
enum privsep_procid id, int n) enum privsep_procid id, int n)
{ {
return (proc_compose_imsg(ps, id, n, imsg->hdr.type, 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 * struct imsgbuf *

View File

@ -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 <reyk@openbsd.org> * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@ -1993,7 +1993,7 @@ relay_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
} }
/* Will validate the result later */ /* Will validate the result later */
con->se_bnds = imsg->fd; con->se_bnds = imsg_get_fd(imsg);
evtimer_del(&con->se_ev); evtimer_del(&con->se_ev);
evtimer_set(&con->se_ev, relay_bindany, con); evtimer_set(&con->se_ev, relay_bindany, con);