summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-container.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-23 19:10:11 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-23 19:10:11 +0100
commitfbadf04511389c4a0687ba5e9baf0ecebdbb07f1 (patch)
treee54a8fe180ebe121a40c70cf23024c3fee77fd3e /src/libsystemd-bus/bus-container.c
parente7f7a1b0222c49fd4706a77bbdac59ac28a4ddbb (diff)
bus: when getting a kdbus connection into a container wait first for child, then read message
There's no EOF generated for AF_UNIX/SOCK_DGRAM sockets, hence let's wait for the child first to see if it succeeded, only then read the socket.
Diffstat (limited to 'src/libsystemd-bus/bus-container.c')
-rw-r--r--src/libsystemd-bus/bus-container.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libsystemd-bus/bus-container.c b/src/libsystemd-bus/bus-container.c
index 1989afa82a..d330363b6f 100644
--- a/src/libsystemd-bus/bus-container.c
+++ b/src/libsystemd-bus/bus-container.c
@@ -205,6 +205,16 @@ int bus_container_connect_kernel(sd_bus *b) {
close_nointr_nofail(pair[1]);
pair[1] = -1;
+ r = wait_for_terminate(child, &si);
+ if (r < 0)
+ return r;
+
+ if (si.si_code != CLD_EXITED)
+ return -EIO;
+
+ if (si.si_status != EXIT_SUCCESS)
+ return -EIO;
+
if (recvmsg(pair[0], &mh, MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) < 0)
return -errno;
@@ -224,16 +234,6 @@ int bus_container_connect_kernel(sd_bus *b) {
fd = fds[0];
}
- r = wait_for_terminate(child, &si);
- if (r < 0)
- return r;
-
- if (si.si_code != CLD_EXITED)
- return -EIO;
-
- if (si.si_status != EXIT_SUCCESS)
- return -EIO;
-
b->input_fd = b->output_fd = fd;
fd = -1;