]> git.proxmox.com Git - mirror_lxc.git/commitdiff
commands: extend rsp_one_fd() to also handle additional data
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 24 Feb 2021 14:31:12 +0000 (15:31 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 24 Feb 2021 14:32:06 +0000 (15:32 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/commands.c

index 95d676ed7d0cac6db7d7f7fee4a06554c430af9b..15d6221e9d11d98c349ab44964885cd9350b7529 100644 (file)
@@ -298,12 +298,18 @@ static inline int lxc_cmd_rsp_send_keep(int fd, struct lxc_cmd_rsp *rsp)
 
 static inline int rsp_one_fd(int fd, int fd_send, struct lxc_cmd_rsp *rsp)
 {
-       int ret;
+       ssize_t ret;
 
        ret = lxc_abstract_unix_send_fds(fd, &fd_send, 1, rsp, sizeof(*rsp));
        if (ret < 0)
                return ret;
 
+       if (rsp->data && rsp->datalen > 0) {
+               ret = lxc_send_nointr(fd, rsp->data, rsp->datalen, MSG_NOSIGNAL);
+               if (ret < 0 || ret != (ssize_t)rsp->datalen)
+                       return syswarn(-errno, "Failed to send command response %zd", ret);
+       }
+
        return LXC_CMD_REAP_CLIENT_FD;
 }