diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-01-25 20:48:01 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-01-27 23:17:02 -0500 |
commit | 8e33886ec582336564ae11b80023abe93d7599c0 (patch) | |
tree | 9d2c70e1a3ba876e78a16e0497a9908ace4f7781 /src/core | |
parent | 847657c7690598f1c77d0ba9e86ef58916bc58a7 (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/core')
-rw-r--r-- | src/core/manager.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index 9d43a1c66e..9ed802398b 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2005,28 +2005,17 @@ void manager_dispatch_bus_name_owner_changed( } int manager_open_serialization(Manager *m, FILE **_f) { - _cleanup_free_ char *path = NULL; + const char *path; int fd = -1; FILE *f; assert(_f); - if (m->running_as == SYSTEMD_SYSTEM) - asprintf(&path, "/run/systemd/dump-"PID_FMT"-XXXXXX", getpid()); - else - asprintf(&path, "/tmp/systemd-dump-"PID_FMT"-XXXXXX", getpid()); - - if (!path) - return -ENOMEM; - - RUN_WITH_UMASK(0077) { - fd = mkostemp(path, O_RDWR|O_CLOEXEC); - } - + path = m->running_as == SYSTEMD_SYSTEM ? "/run/systemd" : "/tmp"; + fd = open_tmpfile(path, O_RDWR|O_CLOEXEC); if (fd < 0) return -errno; - unlink(path); log_debug("Serializing state to %s", path); f = fdopen(fd, "w+"); |