1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

Convert various reyk proc.c daemons over to new imsgbuf_init and

imsgbuf_allow_fdpass.

OK tb@
This commit is contained in:
claudio 2024-11-21 13:38:45 +00:00
parent f1b790a573
commit 6676295ff1
5 changed files with 41 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.20 2024/11/21 13:21:34 claudio Exp $ */
/* $OpenBSD: control.c,v 1.21 2024/11/21 13:38:45 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -159,12 +159,17 @@ control_accept(int listenfd, short event, void *arg)
}
if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) {
close(connfd);
log_warn("%s: calloc", __func__);
close(connfd);
return;
}
imsgbuf_init(&c->iev.ibuf, connfd);
if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) {
log_warn("%s: imsgbuf_init", __func__);
close(connfd);
free(c);
return;
}
c->iev.handler = control_dispatch_imsg;
c->iev.events = EV_READ;
c->iev.data = cs; /* proc.c cheats (reuses the handler) */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.51 2024/11/21 13:21:34 claudio Exp $ */
/* $OpenBSD: proc.c,v 1.52 2024/11/21 13:38:45 claudio Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@ -155,8 +155,10 @@ proc_connect(struct privsep *ps)
for (inst = 0; inst < ps->ps_instances[dst]; inst++) {
iev = &ps->ps_ievs[dst][inst];
imsgbuf_init(&iev->ibuf,
ps->ps_pp->pp_pipes[dst][inst]);
if (imsgbuf_init(&iev->ibuf,
ps->ps_pp->pp_pipes[dst][inst]) == -1)
fatal(NULL);
imsgbuf_allow_fdpass(&iev->ibuf);
event_set(&iev->ev, iev->ibuf.fd, iev->events,
iev->handler, iev->data);
event_add(&iev->ev, NULL);
@ -265,7 +267,9 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst,
pp->pp_pipes[dst][n] = fd;
iev = &ps->ps_ievs[dst][n];
imsgbuf_init(&iev->ibuf, fd);
if (imsgbuf_init(&iev->ibuf, fd) == -1)
fatal(NULL);
imsgbuf_allow_fdpass(&iev->ibuf);
event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data);
event_add(&iev->ev, NULL);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.63 2024/11/21 13:21:34 claudio Exp $ */
/* $OpenBSD: control.c,v 1.64 2024/11/21 13:38:45 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -159,12 +159,18 @@ control_accept(int listenfd, short event, void *arg)
}
if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) {
close(connfd);
log_warn("%s: calloc", __func__);
close(connfd);
return;
}
if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) {
log_warn("%s: imsgbuf_init", __func__);
close(connfd);
free(c);
return;
}
imsgbuf_init(&c->iev.ibuf, connfd);
c->iev.handler = control_dispatch_imsg;
c->iev.events = EV_READ;
c->iev.data = cs; /* proc.c cheats (reuses the handler) */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.51 2024/11/21 13:21:34 claudio Exp $ */
/* $OpenBSD: proc.c,v 1.52 2024/11/21 13:38:45 claudio Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@ -155,8 +155,10 @@ proc_connect(struct privsep *ps)
for (inst = 0; inst < ps->ps_instances[dst]; inst++) {
iev = &ps->ps_ievs[dst][inst];
imsgbuf_init(&iev->ibuf,
ps->ps_pp->pp_pipes[dst][inst]);
if (imsgbuf_init(&iev->ibuf,
ps->ps_pp->pp_pipes[dst][inst]) == -1)
fatal("imsgbuf_init");
imsgbuf_allow_fdpass(&iev->ibuf);
event_set(&iev->ev, iev->ibuf.fd, iev->events,
iev->handler, iev->data);
event_add(&iev->ev, NULL);
@ -265,7 +267,9 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst,
pp->pp_pipes[dst][n] = fd;
iev = &ps->ps_ievs[dst][n];
imsgbuf_init(&iev->ibuf, fd);
if (imsgbuf_init(&iev->ibuf, fd) == -1)
fatal("imsgbuf_init");
imsgbuf_allow_fdpass(&iev->ibuf);
event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data);
event_add(&iev->ev, NULL);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.38 2024/11/21 13:21:34 claudio Exp $ */
/* $OpenBSD: proc.c,v 1.39 2024/11/21 13:38:45 claudio Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@ -155,8 +155,10 @@ proc_connect(struct privsep *ps)
for (inst = 0; inst < ps->ps_instances[dst]; inst++) {
iev = &ps->ps_ievs[dst][inst];
imsgbuf_init(&iev->ibuf,
ps->ps_pp->pp_pipes[dst][inst]);
if (imsgbuf_init(&iev->ibuf,
ps->ps_pp->pp_pipes[dst][inst]) == -1)
fatal("imsgbuf_init");
imsgbuf_allow_fdpass(&iev->ibuf);
event_set(&iev->ev, iev->ibuf.fd, iev->events,
iev->handler, iev->data);
event_add(&iev->ev, NULL);
@ -265,7 +267,9 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst,
pp->pp_pipes[dst][n] = fd;
iev = &ps->ps_ievs[dst][n];
imsgbuf_init(&iev->ibuf, fd);
if (imsgbuf_init(&iev->ibuf, fd) == -1)
fatal("imsgbuf_init");
imsgbuf_allow_fdpass(&iev->ibuf);
event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data);
event_add(&iev->ev, NULL);
}