diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-07-26 17:23:28 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-08-04 16:27:07 +0200 |
commit | 992e8f224b91cacc3d6589bea7882c7ab9c0911b (patch) | |
tree | 7b1869a11a353488ba9c9857f57086e4dc7e046b /src/machine | |
parent | eb18df724ba541ac1c7fd5c77d9244fa6bc5cabf (diff) |
util-lib: rework /tmp and /var/tmp handling code
Beef up the existing var_tmp() call, rename it to var_tmp_dir() and add a
matching tmp_dir() call (the former looks for the place for /var/tmp, the
latter for /tmp).
Both calls check $TMPDIR, $TEMP, $TMP, following the algorithm Python3 uses.
All dirs are validated before use. secure_getenv() is used in order to limite
exposure in suid binaries.
This also ports a couple of users over to these new APIs.
The var_tmp() return parameter is changed from an allocated buffer the caller
will own to a const string either pointing into environ[], or into a static
const buffer. Given that environ[] is mostly considered constant (and this is
exposed in the very well-known getenv() call), this should be OK behaviour and
allows us to avoid memory allocations in most cases.
Note that $TMPDIR and friends override both /var/tmp and /tmp usage if set.
Diffstat (limited to 'src/machine')
-rw-r--r-- | src/machine/machined-dbus.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 1923e8b971..5e2462cba2 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -954,7 +954,7 @@ static int method_clean_pool(sd_bus_message *message, void *userdata, sd_bus_err /* Create a temporary file we can dump information about deleted images into. We use a temporary file for this * instead of a pipe or so, since this might grow quit large in theory and we don't want to process this * continuously */ - result_fd = open_tmpfile_unlinkable("/tmp/", O_RDWR|O_CLOEXEC); + result_fd = open_tmpfile_unlinkable(NULL, O_RDWR|O_CLOEXEC); if (result_fd < 0) return -errno; |