tmpfiles: skip an entry with a relative path

An entry with a path like tmp/file was run on the directory tmpfiles
happened to be started in.  tmpfiles.d(5) only has absolute paths, and
systemd skips such a line.  Do the same, with a warning.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-21 19:23:48 +01:00
1 parent ce5a08e866
commit 4bec72fcf2
4 files changed
+12 -4

No files matched your search

+6 -1
View File
@@ -1628,7 +1628,7 @@ static void replace_kind(const char *path, mode_t fmt)
struct stat st;
/* Nothing is removed by a path that may lead somewhere else */
if (path[0] != '/' || strstr(path, "/./") || strstr(path, "/../"))
if (strstr(path, "/./") || strstr(path, "/../"))
return;
for (size_t len = strlen(copy); len > 1 && copy[len - 1] == '/'; len--)
@@ -1784,6 +1784,11 @@ static void tmpfiles(char *line)
}
path = ptr;
}
if (path[0] != '/') {
if (!quiet)
warnx("Path is not absolute, skipping %s", path);
return;
}
if (excluded(path))
return;
if (collect) {