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.
This commit is contained in:
@@ -451,6 +451,15 @@ static int openpt_in_namespace(pid_t pid, int flags) {
|
||||
close_nointr_nofail(pair[1]);
|
||||
pair[1] = -1;
|
||||
|
||||
r = wait_for_terminate(child, &si);
|
||||
if (r < 0 || si.si_code != CLD_EXITED || si.si_status != EXIT_SUCCESS || master < 0) {
|
||||
|
||||
if (master >= 0)
|
||||
close_nointr_nofail(master);
|
||||
|
||||
return r < 0 ? r : -EIO;
|
||||
}
|
||||
|
||||
if (recvmsg(pair[0], &mh, MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) < 0)
|
||||
return -errno;
|
||||
|
||||
@@ -470,15 +479,6 @@ static int openpt_in_namespace(pid_t pid, int flags) {
|
||||
master = fds[0];
|
||||
}
|
||||
|
||||
r = wait_for_terminate(child, &si);
|
||||
if (r < 0 || si.si_code != CLD_EXITED || si.si_status != EXIT_SUCCESS || master < 0) {
|
||||
|
||||
if (master >= 0)
|
||||
close_nointr_nofail(master);
|
||||
|
||||
return r < 0 ? r : -EIO;
|
||||
}
|
||||
|
||||
return master;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user