The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/3559

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From 185b9ee91b6ca601c509fb65993cbecec187029f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Tue, 20 Oct 2020 17:41:06 +0200
Subject: [PATCH] conf: account for early return when sending devpts fd

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 src/lxc/conf.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index e006ea4391..259d3766ab 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -1549,7 +1549,14 @@ static int lxc_setup_devpts_child(struct lxc_handler 
*handler)
        if (devpts_fd < 0) {
                devpts_fd = -EBADF;
                TRACE("Failed to create detached devpts mount");
+               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");
@@ -1583,16 +1590,8 @@ static int lxc_setup_devpts_child(struct lxc_handler 
*handler)
        ret = symlink("/dev/pts/ptmx", "/dev/ptmx");
        if (ret < 0)
                return log_error_errno(-1, errno, "Failed to create symlink 
from \"/dev/ptmx\" to \"/dev/pts/ptmx\"");
-       DEBUG("Created symlink from \"/dev/ptmx\" to \"/dev/pts/ptmx\"");
 
-       if (devpts_fd < 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);
+       DEBUG("Created symlink from \"/dev/ptmx\" to \"/dev/pts/ptmx\"");
        return 0;
 }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to