The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4553
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) === Closes #4552. Signed-off-by: Christian Brauner <christ...@brauner.io>
From 43777333d369f19fe34c4ab884336c33bd398706 Mon Sep 17 00:00:00 2001 From: Christian Brauner <christ...@brauner.io> Date: Fri, 11 May 2018 12:22:52 +0200 Subject: [PATCH] forkfile: only open O_RDWR if necessary Closes #4552. Signed-off-by: Christian Brauner <christ...@brauner.io> --- lxd/main_forkfile.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lxd/main_forkfile.go b/lxd/main_forkfile.go index 6c68c896d..a27f12736 100644 --- a/lxd/main_forkfile.go +++ b/lxd/main_forkfile.go @@ -66,7 +66,10 @@ int manip_file_in_ns(char *rootfs, int pid, char *host, char *container, bool is ssize_t link_length; if (!is_dir_manip && !is_symlink_manip) { - host_fd = open(host, O_RDWR); + if (is_put) + host_fd = open(host, O_RDWR); + else + host_fd = open(host, O_RDONLY); if (host_fd < 0) { error("error: open"); return -1; @@ -147,9 +150,10 @@ int manip_file_in_ns(char *rootfs, int pid, char *host, char *container, bool is if (fstatat(AT_FDCWD, container, &st, AT_SYMLINK_NOFOLLOW) < 0) exists = 0; - container_open_flags = O_RDWR; if (is_put) - container_open_flags |= O_CREAT; + container_open_flags = O_RDWR | O_CREAT; + else + container_open_flags = O_RDONLY; if (is_put && !is_dir_manip && exists && S_ISDIR(st.st_mode)) { error("error: Path already exists as a directory");
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel