mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: let %T and %V follow $TMPDIR
The %T and %V specifiers are always /tmp and /var/tmp. In systemd both are the first of $TMPDIR, $TEMP, and $TMP that is set to an absolute path of a directory, and only otherwise /tmp and /var/tmp. Do the same. At boot none of them are set, so nothing changes there. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
4 files changed
+29
-4
No files matched your search
+17
-2
@@ -1297,6 +1297,21 @@ static const char *specifier_arch(const char *machine)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* As in systemd, the first of these that names a directory */
|
||||
static const char *specifier_tmp(const char *fallback)
|
||||
{
|
||||
static const char *env[] = { "TMPDIR", "TEMP", "TMP" };
|
||||
|
||||
for (size_t i = 0; i < NELEMS(env); i++) {
|
||||
const char *dir = getenv(env[i]);
|
||||
|
||||
if (dir && dir[0] == '/' && fisdir(dir))
|
||||
return dir;
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/*
|
||||
* The % specifiers of tmpfiles.d(5). tmpfiles runs as root, so the
|
||||
* user ones are fixed. Returns NULL for one that is unknown or has
|
||||
@@ -1315,10 +1330,10 @@ static const char *specifier(char c, char *buf, size_t len)
|
||||
case 'L': return "/var/log";
|
||||
case 'S': return "/var/lib";
|
||||
case 't': return "/run";
|
||||
case 'T': return "/tmp";
|
||||
case 'T': return specifier_tmp("/tmp");
|
||||
case 'u': return "root";
|
||||
case 'U': return "0";
|
||||
case 'V': return "/var/tmp";
|
||||
case 'V': return specifier_tmp("/var/tmp");
|
||||
case 'b':
|
||||
specifier_file("/proc/sys/kernel/random/boot_id", "-", buf, len);
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user