summaryrefslogtreecommitdiff
path: root/src/journal/journal-send.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-01-25 20:48:01 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-01-27 23:17:02 -0500
commit8e33886ec582336564ae11b80023abe93d7599c0 (patch)
tree9d2c70e1a3ba876e78a16e0497a9908ace4f7781 /src/journal/journal-send.c
parent847657c7690598f1c77d0ba9e86ef58916bc58a7 (diff)
Replace mkostemp+unlink with open(O_TMPFILE)
This will only work on Linux >= 3.11, and probably not on all filesystems. Fallback code is provided.
Diffstat (limited to 'src/journal/journal-send.c')
-rw-r--r--src/journal/journal-send.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index 281e154d8e..ca9199f718 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -216,10 +216,6 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
uint8_t buf[CMSG_SPACE(sizeof(int))];
} control;
struct cmsghdr *cmsg;
- /* We use /dev/shm instead of /tmp here, since we want this to
- * be a tmpfs, and one that is available from early boot on
- * and where unprivileged users can create files. */
- char path[] = "/dev/shm/journal.XXXXXX";
bool have_syslog_identifier = false;
assert_return(iov, -EINVAL);
@@ -309,16 +305,14 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
/* Message doesn't fit... Let's dump the data in a temporary
* file and just pass a file descriptor of it to the other
- * side */
-
- buffer_fd = mkostemp(path, O_CLOEXEC|O_RDWR);
+ * side.
+ *
+ * We use /dev/shm instead of /tmp here, since we want this to
+ * be a tmpfs, and one that is available from early boot on
+ * and where unprivileged users can create files. */
+ buffer_fd = open_tmpfile("/dev/shm", O_RDWR | O_CLOEXEC);
if (buffer_fd < 0)
- return -errno;
-
- if (unlink(path) < 0) {
- close_nointr_nofail(buffer_fd);
- return -errno;
- }
+ return buffer_fd;
n = writev(buffer_fd, w, j);
if (n < 0) {