From b121c2f30cec6477cc9fb0b0cfa350ab3e0db98d Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 24 Feb 2021 18:34:14 +0000 Subject: [PATCH] We need to track the pid of the connecting control connection to be able to send answers back to the correct client in case two are connecting at the same time. We also need to pass the pid around to the resolver process so that it can hand it back to us. Debugged by deraadt and dlg who noticed that answers would always arrive on the first control connection. deraadt@ points out that tracking the pid is not the best choice in case one process wants to hold open two connections but at least this brings us in line with all the other privsep daemons with control tools. If we change this we should change it in all daemons. --- sbin/unwind/control.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sbin/unwind/control.c b/sbin/unwind/control.c index 0739beeb22b..a5b2d961df7 100644 --- a/sbin/unwind/control.c +++ b/sbin/unwind/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.16 2021/01/19 16:52:12 florian Exp $ */ +/* $OpenBSD: control.c,v 1.17 2021/02/24 18:34:14 florian Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -272,9 +272,11 @@ control_dispatch_imsg(int fd, short event, void *bula) break; } + c->iev.ibuf.pid = imsg.hdr.pid; switch (imsg.hdr.type) { case IMSG_CTL_RELOAD: - frontend_imsg_compose_main(imsg.hdr.type, 0, NULL, 0); + frontend_imsg_compose_main(imsg.hdr.type, imsg.hdr.pid, + NULL, 0); break; case IMSG_CTL_LOG_VERBOSE: if (IMSG_DATA_SIZE(imsg) != sizeof(verbose)) @@ -294,8 +296,8 @@ control_dispatch_imsg(int fd, short event, void *bula) case IMSG_CTL_MEM: if (IMSG_DATA_SIZE(imsg) != 0) break; - frontend_imsg_compose_resolver(imsg.hdr.type, 0, NULL, - 0); + frontend_imsg_compose_resolver(imsg.hdr.type, + imsg.hdr.pid, NULL, 0); break; default: log_debug("%s: error handling imsg %d", __func__, -- 2.20.1