Skip to content

Commit

Permalink
ringbuf: fix temporary file creation
Browse files Browse the repository at this point in the history
lxc_make_tmpfile() uses mkstemp() internally, and thus expects the
template to contain 'XXXXXX' and be writable.

Signed-off-by: Thomas Moschny <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
Christian Brauner committed Apr 6, 2018
1 parent a324e7e commit 709384a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lxc/ringbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 709384a

Please sign in to comment.