Blame


1 dd038bc6 2021-09-21 thomas.ad /* $OpenBSD: imsg.c,v 1.16 2017/12/14 09:27:44 kettenis Exp $ */
2 dd038bc6 2021-09-21 thomas.ad
3 dd038bc6 2021-09-21 thomas.ad /*
4 dd038bc6 2021-09-21 thomas.ad * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
5 dd038bc6 2021-09-21 thomas.ad *
6 dd038bc6 2021-09-21 thomas.ad * Permission to use, copy, modify, and distribute this software for any
7 dd038bc6 2021-09-21 thomas.ad * purpose with or without fee is hereby granted, provided that the above
8 dd038bc6 2021-09-21 thomas.ad * copyright notice and this permission notice appear in all copies.
9 dd038bc6 2021-09-21 thomas.ad *
10 dd038bc6 2021-09-21 thomas.ad * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 dd038bc6 2021-09-21 thomas.ad * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 dd038bc6 2021-09-21 thomas.ad * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 dd038bc6 2021-09-21 thomas.ad * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 dd038bc6 2021-09-21 thomas.ad * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 dd038bc6 2021-09-21 thomas.ad * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 dd038bc6 2021-09-21 thomas.ad * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 dd038bc6 2021-09-21 thomas.ad */
18 dd038bc6 2021-09-21 thomas.ad
19 dd038bc6 2021-09-21 thomas.ad #include <sys/types.h>
20 dd038bc6 2021-09-21 thomas.ad #include <sys/socket.h>
21 dd038bc6 2021-09-21 thomas.ad #include <sys/uio.h>
22 dd038bc6 2021-09-21 thomas.ad
23 dd038bc6 2021-09-21 thomas.ad #include <errno.h>
24 dd038bc6 2021-09-21 thomas.ad #include <stdlib.h>
25 dd038bc6 2021-09-21 thomas.ad #include <string.h>
26 dd038bc6 2021-09-21 thomas.ad #include <unistd.h>
27 dd038bc6 2021-09-21 thomas.ad
28 dd038bc6 2021-09-21 thomas.ad #include "got_compat.h"
29 dd038bc6 2021-09-21 thomas.ad #include "imsg.h"
30 dd038bc6 2021-09-21 thomas.ad
31 dd038bc6 2021-09-21 thomas.ad int imsg_fd_overhead = 0;
32 dd038bc6 2021-09-21 thomas.ad
33 dd038bc6 2021-09-21 thomas.ad static int imsg_get_fd(struct imsgbuf *);
34 dd038bc6 2021-09-21 thomas.ad
35 dd038bc6 2021-09-21 thomas.ad void
36 dd038bc6 2021-09-21 thomas.ad imsg_init(struct imsgbuf *ibuf, int fd)
37 dd038bc6 2021-09-21 thomas.ad {
38 dd038bc6 2021-09-21 thomas.ad msgbuf_init(&ibuf->w);
39 dd038bc6 2021-09-21 thomas.ad memset(&ibuf->r, 0, sizeof(ibuf->r));
40 dd038bc6 2021-09-21 thomas.ad ibuf->fd = fd;
41 dd038bc6 2021-09-21 thomas.ad ibuf->w.fd = fd;
42 dd038bc6 2021-09-21 thomas.ad ibuf->pid = getpid();
43 dd038bc6 2021-09-21 thomas.ad TAILQ_INIT(&ibuf->fds);
44 dd038bc6 2021-09-21 thomas.ad }
45 dd038bc6 2021-09-21 thomas.ad
46 dd038bc6 2021-09-21 thomas.ad ssize_t
47 dd038bc6 2021-09-21 thomas.ad imsg_read(struct imsgbuf *ibuf)
48 dd038bc6 2021-09-21 thomas.ad {
49 dd038bc6 2021-09-21 thomas.ad struct msghdr msg;
50 dd038bc6 2021-09-21 thomas.ad struct cmsghdr *cmsg;
51 dd038bc6 2021-09-21 thomas.ad union {
52 dd038bc6 2021-09-21 thomas.ad struct cmsghdr hdr;
53 dd038bc6 2021-09-21 thomas.ad char buf[CMSG_SPACE(sizeof(int) * 1)];
54 dd038bc6 2021-09-21 thomas.ad } cmsgbuf;
55 dd038bc6 2021-09-21 thomas.ad struct iovec iov;
56 dd038bc6 2021-09-21 thomas.ad ssize_t n = -1;
57 dd038bc6 2021-09-21 thomas.ad int fd;
58 dd038bc6 2021-09-21 thomas.ad struct imsg_fd *ifd;
59 dd038bc6 2021-09-21 thomas.ad
60 dd038bc6 2021-09-21 thomas.ad memset(&msg, 0, sizeof(msg));
61 dd038bc6 2021-09-21 thomas.ad memset(&cmsgbuf, 0, sizeof(cmsgbuf));
62 dd038bc6 2021-09-21 thomas.ad
63 dd038bc6 2021-09-21 thomas.ad iov.iov_base = ibuf->r.buf + ibuf->r.wpos;
64 dd038bc6 2021-09-21 thomas.ad iov.iov_len = sizeof(ibuf->r.buf) - ibuf->r.wpos;
65 dd038bc6 2021-09-21 thomas.ad msg.msg_iov = &iov;
66 dd038bc6 2021-09-21 thomas.ad msg.msg_iovlen = 1;
67 dd038bc6 2021-09-21 thomas.ad msg.msg_control = &cmsgbuf.buf;
68 dd038bc6 2021-09-21 thomas.ad msg.msg_controllen = sizeof(cmsgbuf.buf);
69 dd038bc6 2021-09-21 thomas.ad
70 dd038bc6 2021-09-21 thomas.ad if ((ifd = calloc(1, sizeof(struct imsg_fd))) == NULL)
71 dd038bc6 2021-09-21 thomas.ad return (-1);
72 dd038bc6 2021-09-21 thomas.ad
73 dd038bc6 2021-09-21 thomas.ad again:
74 dd038bc6 2021-09-21 thomas.ad if (getdtablecount() + imsg_fd_overhead +
75 dd038bc6 2021-09-21 thomas.ad (int)((CMSG_SPACE(sizeof(int))-CMSG_SPACE(0))/sizeof(int))
76 dd038bc6 2021-09-21 thomas.ad >= getdtablesize()) {
77 dd038bc6 2021-09-21 thomas.ad errno = EAGAIN;
78 dd038bc6 2021-09-21 thomas.ad free(ifd);
79 dd038bc6 2021-09-21 thomas.ad return (-1);
80 dd038bc6 2021-09-21 thomas.ad }
81 dd038bc6 2021-09-21 thomas.ad
82 dd038bc6 2021-09-21 thomas.ad if ((n = recvmsg(ibuf->fd, &msg, 0)) == -1) {
83 dd038bc6 2021-09-21 thomas.ad if (errno == EINTR)
84 dd038bc6 2021-09-21 thomas.ad goto again;
85 dd038bc6 2021-09-21 thomas.ad goto fail;
86 dd038bc6 2021-09-21 thomas.ad }
87 dd038bc6 2021-09-21 thomas.ad
88 dd038bc6 2021-09-21 thomas.ad ibuf->r.wpos += n;
89 dd038bc6 2021-09-21 thomas.ad
90 dd038bc6 2021-09-21 thomas.ad for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
91 dd038bc6 2021-09-21 thomas.ad cmsg = CMSG_NXTHDR(&msg, cmsg)) {
92 dd038bc6 2021-09-21 thomas.ad if (cmsg->cmsg_level == SOL_SOCKET &&
93 dd038bc6 2021-09-21 thomas.ad cmsg->cmsg_type == SCM_RIGHTS) {
94 dd038bc6 2021-09-21 thomas.ad int i;
95 dd038bc6 2021-09-21 thomas.ad int j;
96 dd038bc6 2021-09-21 thomas.ad
97 dd038bc6 2021-09-21 thomas.ad /*
98 dd038bc6 2021-09-21 thomas.ad * We only accept one file descriptor. Due to C
99 dd038bc6 2021-09-21 thomas.ad * padding rules, our control buffer might contain
100 dd038bc6 2021-09-21 thomas.ad * more than one fd, and we must close them.
101 dd038bc6 2021-09-21 thomas.ad */
102 dd038bc6 2021-09-21 thomas.ad j = ((char *)cmsg + cmsg->cmsg_len -
103 dd038bc6 2021-09-21 thomas.ad (char *)CMSG_DATA(cmsg)) / sizeof(int);
104 dd038bc6 2021-09-21 thomas.ad for (i = 0; i < j; i++) {
105 dd038bc6 2021-09-21 thomas.ad fd = ((int *)CMSG_DATA(cmsg))[i];
106 dd038bc6 2021-09-21 thomas.ad if (ifd != NULL) {
107 dd038bc6 2021-09-21 thomas.ad ifd->fd = fd;
108 dd038bc6 2021-09-21 thomas.ad TAILQ_INSERT_TAIL(&ibuf->fds, ifd,
109 dd038bc6 2021-09-21 thomas.ad entry);
110 dd038bc6 2021-09-21 thomas.ad ifd = NULL;
111 dd038bc6 2021-09-21 thomas.ad } else
112 dd038bc6 2021-09-21 thomas.ad close(fd);
113 dd038bc6 2021-09-21 thomas.ad }
114 dd038bc6 2021-09-21 thomas.ad }
115 dd038bc6 2021-09-21 thomas.ad /* we do not handle other ctl data level */
116 dd038bc6 2021-09-21 thomas.ad }
117 dd038bc6 2021-09-21 thomas.ad
118 dd038bc6 2021-09-21 thomas.ad fail:
119 dd038bc6 2021-09-21 thomas.ad free(ifd);
120 dd038bc6 2021-09-21 thomas.ad return (n);
121 dd038bc6 2021-09-21 thomas.ad }
122 dd038bc6 2021-09-21 thomas.ad
123 dd038bc6 2021-09-21 thomas.ad ssize_t
124 dd038bc6 2021-09-21 thomas.ad imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
125 dd038bc6 2021-09-21 thomas.ad {
126 dd038bc6 2021-09-21 thomas.ad size_t av, left, datalen;
127 dd038bc6 2021-09-21 thomas.ad
128 dd038bc6 2021-09-21 thomas.ad av = ibuf->r.wpos;
129 dd038bc6 2021-09-21 thomas.ad
130 dd038bc6 2021-09-21 thomas.ad if (IMSG_HEADER_SIZE > av)
131 dd038bc6 2021-09-21 thomas.ad return (0);
132 dd038bc6 2021-09-21 thomas.ad
133 dd038bc6 2021-09-21 thomas.ad memcpy(&imsg->hdr, ibuf->r.buf, sizeof(imsg->hdr));
134 dd038bc6 2021-09-21 thomas.ad if (imsg->hdr.len < IMSG_HEADER_SIZE ||
135 dd038bc6 2021-09-21 thomas.ad imsg->hdr.len > MAX_IMSGSIZE) {
136 dd038bc6 2021-09-21 thomas.ad errno = ERANGE;
137 dd038bc6 2021-09-21 thomas.ad return (-1);
138 dd038bc6 2021-09-21 thomas.ad }
139 dd038bc6 2021-09-21 thomas.ad if (imsg->hdr.len > av)
140 dd038bc6 2021-09-21 thomas.ad return (0);
141 dd038bc6 2021-09-21 thomas.ad datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
142 dd038bc6 2021-09-21 thomas.ad ibuf->r.rptr = ibuf->r.buf + IMSG_HEADER_SIZE;
143 dd038bc6 2021-09-21 thomas.ad if (datalen == 0)
144 dd038bc6 2021-09-21 thomas.ad imsg->data = NULL;
145 dd038bc6 2021-09-21 thomas.ad else if ((imsg->data = malloc(datalen)) == NULL)
146 dd038bc6 2021-09-21 thomas.ad return (-1);
147 dd038bc6 2021-09-21 thomas.ad
148 dd038bc6 2021-09-21 thomas.ad if (imsg->hdr.flags & IMSGF_HASFD)
149 dd038bc6 2021-09-21 thomas.ad imsg->fd = imsg_get_fd(ibuf);
150 dd038bc6 2021-09-21 thomas.ad else
151 dd038bc6 2021-09-21 thomas.ad imsg->fd = -1;
152 dd038bc6 2021-09-21 thomas.ad
153 dd038bc6 2021-09-21 thomas.ad memcpy(imsg->data, ibuf->r.rptr, datalen);
154 dd038bc6 2021-09-21 thomas.ad
155 dd038bc6 2021-09-21 thomas.ad if (imsg->hdr.len < av) {
156 dd038bc6 2021-09-21 thomas.ad left = av - imsg->hdr.len;
157 dd038bc6 2021-09-21 thomas.ad memmove(&ibuf->r.buf, ibuf->r.buf + imsg->hdr.len, left);
158 dd038bc6 2021-09-21 thomas.ad ibuf->r.wpos = left;
159 dd038bc6 2021-09-21 thomas.ad } else
160 dd038bc6 2021-09-21 thomas.ad ibuf->r.wpos = 0;
161 dd038bc6 2021-09-21 thomas.ad
162 dd038bc6 2021-09-21 thomas.ad return (datalen + IMSG_HEADER_SIZE);
163 dd038bc6 2021-09-21 thomas.ad }
164 dd038bc6 2021-09-21 thomas.ad
165 dd038bc6 2021-09-21 thomas.ad int
166 dd038bc6 2021-09-21 thomas.ad imsg_compose(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, pid_t pid,
167 dd038bc6 2021-09-21 thomas.ad int fd, const void *data, uint16_t datalen)
168 dd038bc6 2021-09-21 thomas.ad {
169 dd038bc6 2021-09-21 thomas.ad struct ibuf *wbuf;
170 dd038bc6 2021-09-21 thomas.ad
171 dd038bc6 2021-09-21 thomas.ad if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)
172 dd038bc6 2021-09-21 thomas.ad return (-1);
173 dd038bc6 2021-09-21 thomas.ad
174 dd038bc6 2021-09-21 thomas.ad if (imsg_add(wbuf, data, datalen) == -1)
175 dd038bc6 2021-09-21 thomas.ad return (-1);
176 dd038bc6 2021-09-21 thomas.ad
177 dd038bc6 2021-09-21 thomas.ad wbuf->fd = fd;
178 dd038bc6 2021-09-21 thomas.ad
179 dd038bc6 2021-09-21 thomas.ad imsg_close(ibuf, wbuf);
180 dd038bc6 2021-09-21 thomas.ad
181 dd038bc6 2021-09-21 thomas.ad return (1);
182 dd038bc6 2021-09-21 thomas.ad }
183 dd038bc6 2021-09-21 thomas.ad
184 dd038bc6 2021-09-21 thomas.ad int
185 dd038bc6 2021-09-21 thomas.ad imsg_composev(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, pid_t pid,
186 dd038bc6 2021-09-21 thomas.ad int fd, const struct iovec *iov, int iovcnt)
187 dd038bc6 2021-09-21 thomas.ad {
188 dd038bc6 2021-09-21 thomas.ad struct ibuf *wbuf;
189 dd038bc6 2021-09-21 thomas.ad int i, datalen = 0;
190 dd038bc6 2021-09-21 thomas.ad
191 dd038bc6 2021-09-21 thomas.ad for (i = 0; i < iovcnt; i++)
192 dd038bc6 2021-09-21 thomas.ad datalen += iov[i].iov_len;
193 dd038bc6 2021-09-21 thomas.ad
194 dd038bc6 2021-09-21 thomas.ad if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)
195 dd038bc6 2021-09-21 thomas.ad return (-1);
196 dd038bc6 2021-09-21 thomas.ad
197 dd038bc6 2021-09-21 thomas.ad for (i = 0; i < iovcnt; i++)
198 dd038bc6 2021-09-21 thomas.ad if (imsg_add(wbuf, iov[i].iov_base, iov[i].iov_len) == -1)
199 dd038bc6 2021-09-21 thomas.ad return (-1);
200 dd038bc6 2021-09-21 thomas.ad
201 dd038bc6 2021-09-21 thomas.ad wbuf->fd = fd;
202 dd038bc6 2021-09-21 thomas.ad
203 dd038bc6 2021-09-21 thomas.ad imsg_close(ibuf, wbuf);
204 dd038bc6 2021-09-21 thomas.ad
205 dd038bc6 2021-09-21 thomas.ad return (1);
206 dd038bc6 2021-09-21 thomas.ad }
207 dd038bc6 2021-09-21 thomas.ad
208 dd038bc6 2021-09-21 thomas.ad /* ARGSUSED */
209 dd038bc6 2021-09-21 thomas.ad struct ibuf *
210 dd038bc6 2021-09-21 thomas.ad imsg_create(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, pid_t pid,
211 dd038bc6 2021-09-21 thomas.ad uint16_t datalen)
212 dd038bc6 2021-09-21 thomas.ad {
213 dd038bc6 2021-09-21 thomas.ad struct ibuf *wbuf;
214 dd038bc6 2021-09-21 thomas.ad struct imsg_hdr hdr;
215 dd038bc6 2021-09-21 thomas.ad
216 dd038bc6 2021-09-21 thomas.ad datalen += IMSG_HEADER_SIZE;
217 dd038bc6 2021-09-21 thomas.ad if (datalen > MAX_IMSGSIZE) {
218 dd038bc6 2021-09-21 thomas.ad errno = ERANGE;
219 dd038bc6 2021-09-21 thomas.ad return (NULL);
220 dd038bc6 2021-09-21 thomas.ad }
221 dd038bc6 2021-09-21 thomas.ad
222 dd038bc6 2021-09-21 thomas.ad hdr.type = type;
223 dd038bc6 2021-09-21 thomas.ad hdr.flags = 0;
224 dd038bc6 2021-09-21 thomas.ad hdr.peerid = peerid;
225 dd038bc6 2021-09-21 thomas.ad if ((hdr.pid = pid) == 0)
226 dd038bc6 2021-09-21 thomas.ad hdr.pid = ibuf->pid;
227 dd038bc6 2021-09-21 thomas.ad if ((wbuf = ibuf_dynamic(datalen, MAX_IMSGSIZE)) == NULL) {
228 dd038bc6 2021-09-21 thomas.ad return (NULL);
229 dd038bc6 2021-09-21 thomas.ad }
230 dd038bc6 2021-09-21 thomas.ad if (imsg_add(wbuf, &hdr, sizeof(hdr)) == -1)
231 dd038bc6 2021-09-21 thomas.ad return (NULL);
232 dd038bc6 2021-09-21 thomas.ad
233 dd038bc6 2021-09-21 thomas.ad return (wbuf);
234 dd038bc6 2021-09-21 thomas.ad }
235 dd038bc6 2021-09-21 thomas.ad
236 dd038bc6 2021-09-21 thomas.ad int
237 dd038bc6 2021-09-21 thomas.ad imsg_add(struct ibuf *msg, const void *data, uint16_t datalen)
238 dd038bc6 2021-09-21 thomas.ad {
239 dd038bc6 2021-09-21 thomas.ad if (datalen)
240 dd038bc6 2021-09-21 thomas.ad if (ibuf_add(msg, data, datalen) == -1) {
241 dd038bc6 2021-09-21 thomas.ad ibuf_free(msg);
242 dd038bc6 2021-09-21 thomas.ad return (-1);
243 dd038bc6 2021-09-21 thomas.ad }
244 dd038bc6 2021-09-21 thomas.ad return (datalen);
245 dd038bc6 2021-09-21 thomas.ad }
246 dd038bc6 2021-09-21 thomas.ad
247 dd038bc6 2021-09-21 thomas.ad void
248 dd038bc6 2021-09-21 thomas.ad imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
249 dd038bc6 2021-09-21 thomas.ad {
250 dd038bc6 2021-09-21 thomas.ad struct imsg_hdr *hdr;
251 dd038bc6 2021-09-21 thomas.ad
252 dd038bc6 2021-09-21 thomas.ad hdr = (struct imsg_hdr *)msg->buf;
253 dd038bc6 2021-09-21 thomas.ad
254 dd038bc6 2021-09-21 thomas.ad hdr->flags &= ~IMSGF_HASFD;
255 dd038bc6 2021-09-21 thomas.ad if (msg->fd != -1)
256 dd038bc6 2021-09-21 thomas.ad hdr->flags |= IMSGF_HASFD;
257 dd038bc6 2021-09-21 thomas.ad
258 dd038bc6 2021-09-21 thomas.ad hdr->len = (uint16_t)msg->wpos;
259 dd038bc6 2021-09-21 thomas.ad
260 dd038bc6 2021-09-21 thomas.ad ibuf_close(&ibuf->w, msg);
261 dd038bc6 2021-09-21 thomas.ad }
262 dd038bc6 2021-09-21 thomas.ad
263 dd038bc6 2021-09-21 thomas.ad void
264 dd038bc6 2021-09-21 thomas.ad imsg_free(struct imsg *imsg)
265 dd038bc6 2021-09-21 thomas.ad {
266 dd038bc6 2021-09-21 thomas.ad freezero(imsg->data, imsg->hdr.len - IMSG_HEADER_SIZE);
267 dd038bc6 2021-09-21 thomas.ad }
268 dd038bc6 2021-09-21 thomas.ad
269 dd038bc6 2021-09-21 thomas.ad static int
270 dd038bc6 2021-09-21 thomas.ad imsg_get_fd(struct imsgbuf *ibuf)
271 dd038bc6 2021-09-21 thomas.ad {
272 dd038bc6 2021-09-21 thomas.ad int fd;
273 dd038bc6 2021-09-21 thomas.ad struct imsg_fd *ifd;
274 dd038bc6 2021-09-21 thomas.ad
275 dd038bc6 2021-09-21 thomas.ad if ((ifd = TAILQ_FIRST(&ibuf->fds)) == NULL)
276 dd038bc6 2021-09-21 thomas.ad return (-1);
277 dd038bc6 2021-09-21 thomas.ad
278 dd038bc6 2021-09-21 thomas.ad fd = ifd->fd;
279 dd038bc6 2021-09-21 thomas.ad TAILQ_REMOVE(&ibuf->fds, ifd, entry);
280 dd038bc6 2021-09-21 thomas.ad free(ifd);
281 dd038bc6 2021-09-21 thomas.ad
282 dd038bc6 2021-09-21 thomas.ad return (fd);
283 dd038bc6 2021-09-21 thomas.ad }
284 dd038bc6 2021-09-21 thomas.ad
285 dd038bc6 2021-09-21 thomas.ad int
286 dd038bc6 2021-09-21 thomas.ad imsg_flush(struct imsgbuf *ibuf)
287 dd038bc6 2021-09-21 thomas.ad {
288 dd038bc6 2021-09-21 thomas.ad while (ibuf->w.queued)
289 dd038bc6 2021-09-21 thomas.ad if (msgbuf_write(&ibuf->w) <= 0)
290 dd038bc6 2021-09-21 thomas.ad return (-1);
291 dd038bc6 2021-09-21 thomas.ad return (0);
292 dd038bc6 2021-09-21 thomas.ad }
293 dd038bc6 2021-09-21 thomas.ad
294 dd038bc6 2021-09-21 thomas.ad void
295 dd038bc6 2021-09-21 thomas.ad imsg_clear(struct imsgbuf *ibuf)
296 dd038bc6 2021-09-21 thomas.ad {
297 dd038bc6 2021-09-21 thomas.ad int fd;
298 dd038bc6 2021-09-21 thomas.ad
299 dd038bc6 2021-09-21 thomas.ad msgbuf_clear(&ibuf->w);
300 dd038bc6 2021-09-21 thomas.ad while ((fd = imsg_get_fd(ibuf)) != -1)
301 dd038bc6 2021-09-21 thomas.ad close(fd);
302 dd038bc6 2021-09-21 thomas.ad }