start: improve devpts fd sending

Closes: #3549. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 49f04965
......@@ -1531,13 +1531,15 @@ static int lxc_setup_devpts(struct lxc_handler *handler)
devpts_fd = openat(-EBADF, "/dev/pts", O_CLOEXEC | O_DIRECTORY | O_PATH | O_NOFOLLOW);
if (devpts_fd < 0) {
devpts_fd = -EBADF;
TRACE("Failed to create detached devpts mount");
ret = lxc_abstract_unix_send_fds(sock, NULL, 0, NULL, 0);
ret = lxc_abstract_unix_send_fds(sock, NULL, 0, &devpts_fd, sizeof(int));
} else {
ret = lxc_abstract_unix_send_fds(sock, &devpts_fd, 1, NULL, 0);
}
if (ret < 0)
return log_error_errno(-1, errno, "Failed to send devpts fd to parent");
TRACE("Sent devpts file descriptor %d to parent", devpts_fd);
/* Remove any pre-existing /dev/ptmx file. */
ret = remove("/dev/ptmx");
......
......@@ -1878,13 +1878,14 @@ static int lxc_spawn(struct lxc_handler *handler)
}
}
ret = lxc_abstract_unix_recv_fds(data_sock1, &handler->conf->devpts_fd, 1, NULL, 0);
ret = lxc_abstract_unix_recv_fds(data_sock1, &handler->conf->devpts_fd, 1,
&handler->conf->devpts_fd,
sizeof(handler->conf->devpts_fd));
if (ret < 0) {
SYSERROR("Failed to receive devpts fd from child");
goto out_delete_net;
}
if (ret == 0)
handler->conf->devpts_fd = -EBADF;
TRACE("Received devpts file descriptor %d from child", handler->conf->devpts_fd);
/* Now all networks are created, network devices are moved into place,
* and the correct names and ifindices in the respective namespaces have
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment