[lxc-devel] [lxc/master] Fix temp file creation
brauner on Github
lxc-bot at linuxcontainers.org
Fri Apr 6 09:00:14 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 850 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180406/66f31ec7/attachment.bin>
-------------- next part --------------
From a324e7eba0d954ab6f9dafad09efaa67f4aeaa9e Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 6 Apr 2018 10:54:02 +0200
Subject: [PATCH 1/2] conf: fix temporary file creation
lxc_make_tmpfile() uses mkstemp() internally, and thus expects the
template to contain 'XXXXXX' and be writable.
Signed-off-by: Thomas Moschny <thomas.moschny at gmx.de>
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/conf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 745584308..09095ff9f 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2286,9 +2286,12 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount)
fd = memfd_create(".lxc_mount_file", MFD_CLOEXEC);
if (fd < 0) {
+ char template[] = P_tmpdir "/.lxc_mount_file_XXXXXX";
+
if (errno != ENOSYS)
return NULL;
- fd = lxc_make_tmpfile((char *){P_tmpdir "/.lxc_mount_file"}, true);
+
+ fd = lxc_make_tmpfile(template, true);
if (fd < 0) {
SYSERROR("Could not create temporary mount file");
return NULL;
From 709384a02e74f76d59dc6f2903aab1679e9b2839 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 6 Apr 2018 10:54:41 +0200
Subject: [PATCH 2/2] ringbuf: fix temporary file creation
lxc_make_tmpfile() uses mkstemp() internally, and thus expects the
template to contain 'XXXXXX' and be writable.
Signed-off-by: Thomas Moschny <thomas.moschny at gmx.de>
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/ringbuf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/lxc/ringbuf.c b/src/lxc/ringbuf.c
index 1299fe709..7aa2e6310 100644
--- a/src/lxc/ringbuf.c
+++ b/src/lxc/ringbuf.c
@@ -52,10 +52,12 @@ int lxc_ringbuf_create(struct lxc_ringbuf *buf, size_t size)
memfd = memfd_create(".lxc_ringbuf", MFD_CLOEXEC);
if (memfd < 0) {
+ char template[] = P_tmpdir "/.lxc_ringbuf_XXXXXX";
+
if (errno != ENOSYS)
goto on_error;
- memfd = lxc_make_tmpfile((char *){P_tmpdir"/.lxc_ringbuf_XXXXXX"}, true);
+ memfd = lxc_make_tmpfile(template, true);
}
if (memfd < 0)
goto on_error;
More information about the lxc-devel
mailing list