]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: Return detailed (sd-buscntr) error from bus_container_connect_socket()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 19 Aug 2021 14:09:34 +0000 (15:09 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 19 Aug 2021 14:47:24 +0000 (15:47 +0100)
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

index 1159af46cdf25ebb98764e7634d6b4bd7cfdecfd..17bbca7deb3a684c943853e9317c40fb7c6fa07c 100644 (file)
@@ -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);
 }