From 709384a02e74f76d59dc6f2903aab1679e9b2839 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Fri, 6 Apr 2018 10:54:41 +0200 Subject: [PATCH] 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 Signed-off-by: Christian Brauner --- 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 1299fe7090..7aa2e6310e 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;