From: Daan De Meyer Date: Thu, 19 Aug 2021 14:09:34 +0000 (+0100) Subject: sd-bus: Return detailed (sd-buscntr) error from bus_container_connect_socket() X-Git-Tag: v250-rc1~802^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=405a028e65090571461a2d5c6e5eb66659da91a3;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/libsystemd/sd-bus/bus-container.c b/src/libsystemd/sd-bus/bus-container.c index 1159af46cdf..17bbca7deb3 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); }