]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: account for early return when sending devpts fd 3559/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 20 Oct 2020 15:41:06 +0000 (17:41 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 20 Oct 2020 15:41:06 +0000 (17:41 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index e006ea43915dde595b4dd45da8330687aa2c533f..259d3766ab24d6fb1d8d5cc61a219dcd7a4e99b4 100644 (file)
@@ -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;
 }