From fbadf04511389c4a0687ba5e9baf0ecebdbb07f1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 23 Dec 2013 19:10:11 +0100 Subject: 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. --- src/libsystemd-bus/bus-container.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/libsystemd-bus') 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; -- cgit v1.2.3-54-g00ecf