summaryrefslogtreecommitdiff
path: root/src/shared/specifier.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-05-29 11:25:26 +0200
committerLennart Poettering <lennart@poettering.net>2018-05-29 11:39:15 +0200
commitb294e5943f06bc96e2898e769cfe610bbf10b767 (patch)
treee6b7188d1af3b78d88a5ca6d60849cddf7bf5a93 /src/shared/specifier.c
parent709f4c472cd907d0924fdf4982e4a4d49e44ec4d (diff)
downloadsystemd-b294e5943f06bc96e2898e769cfe610bbf10b767.tar.gz
core: introduce specifiers for /tmp and /var/tmp
This corresponds nicely with the specifiers we already pass for /var/lib, /var/cache, /run and so on. This is particular useful to update the test-path service files to operate without guessable files, thus allowing multiple parallel test-path invocations to pass without issues (the idea is to set $TMPDIR early on in the test to some private directory, and then only use the new %T or %V specifier to refer to it).
Diffstat (limited to 'src/shared/specifier.c')
-rw-r--r--src/shared/specifier.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/shared/specifier.c b/src/shared/specifier.c
index 27782b8d5b..c4b2bdc12d 100644
--- a/src/shared/specifier.c
+++ b/src/shared/specifier.c
@@ -15,6 +15,7 @@
#include "sd-id128.h"
#include "alloc-util.h"
+#include "fs-util.h"
#include "hostname-util.h"
#include "macro.h"
#include "specifier.h"
@@ -222,6 +223,40 @@ int specifier_user_shell(char specifier, void *data, void *userdata, char **ret)
return get_shell(ret);
}
+int specifier_tmp_dir(char specifier, void *data, void *userdata, char **ret) {
+ const char *p;
+ char *copy;
+ int r;
+
+ r = tmp_dir(&p);
+ if (r < 0)
+ return r;
+
+ copy = strdup(p);
+ if (!copy)
+ return -ENOMEM;
+
+ *ret = copy;
+ return 0;
+}
+
+int specifier_var_tmp_dir(char specifier, void *data, void *userdata, char **ret) {
+ const char *p;
+ char *copy;
+ int r;
+
+ r = var_tmp_dir(&p);
+ if (r < 0)
+ return r;
+
+ copy = strdup(p);
+ if (!copy)
+ return -ENOMEM;
+
+ *ret = copy;
+ return 0;
+}
+
int specifier_escape_strv(char **l, char ***ret) {
char **z, **p, **q;