From 405a028e65090571461a2d5c6e5eb66659da91a3 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 19 Aug 2021 15:09:34 +0100 Subject: [PATCH] sd-bus: Return detailed (sd-buscntr) error from bus_container_connect_socket() Previously, when the connect() call in (sd-buscntr) failed, we returned -EPROTO without ever reading the actual errno from the error pipe. To fix the issue, delay checking the process exit status until after we've read and processed any error from the error pipe. --- src/libsystemd/sd-bus/bus-container.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libsystemd/sd-bus/bus-container.c b/src/libsystemd/sd-bus/bus-container.c index 1159af46cd..17bbca7deb 100644 --- a/src/libsystemd/sd-bus/bus-container.c +++ b/src/libsystemd/sd-bus/bus-container.c @@ -75,8 +75,7 @@ int bus_container_connect_socket(sd_bus *b) { r = wait_for_terminate_and_check("(sd-buscntrns)", child, 0); if (r < 0) return r; - if (r != EXIT_SUCCESS) - return -EPROTO; + bool nonzero_exit_status = r != EXIT_SUCCESS; n = read(pair[0], &error_buf, sizeof(error_buf)); if (n < 0) @@ -98,5 +97,8 @@ int bus_container_connect_socket(sd_bus *b) { return log_debug_errno(error_buf, "Got error from (sd-buscntr): %m"); } + if (nonzero_exit_status) + return -EPROTO; + return bus_socket_start_auth(b); }