mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
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:
4 files changed
+12
-4
No files matched your search
@@ -348,6 +348,9 @@ All relevant changes are documented in this file.
|
|||||||
entry in Finit's own `etc.conf`. A file was copied over an existing
|
entry in Finit's own `etc.conf`. A file was copied over an existing
|
||||||
one. As in tmpfiles.d(5), nothing that exists is now overwritten, and
|
one. As in tmpfiles.d(5), nothing that exists is now overwritten, and
|
||||||
links are copied as links
|
links are copied as links
|
||||||
|
- Fix tmpfiles entries with a relative path, they were run on whatever
|
||||||
|
directory `tmpfiles` was started in. As in tmpfiles.d(5), such an
|
||||||
|
entry is now skipped with a warning
|
||||||
- Fix logins refused after boot on a system with systemd's tmpfiles.d
|
- Fix logins refused after boot on a system with systemd's tmpfiles.d
|
||||||
files installed. They create `/run/nologin` at boot, and on systemd it
|
files installed. They create `/run/nologin` at boot, and on systemd it
|
||||||
is removed by systemd-user-sessions. Finit now removes it when leaving
|
is removed by systemd-user-sessions. Finit now removes it when leaving
|
||||||
|
|||||||
@@ -30,5 +30,3 @@ Missing options: `--root`, `--replace`, and `--purge`.
|
|||||||
first and Finit runs both, so the last one wins. Today that is the
|
first and Finit runs both, so the last one wins. Today that is the
|
||||||
one in `/etc`, which is what an admin expects. Sorted by name it
|
one in `/etc`, which is what an admin expects. Sorted by name it
|
||||||
would be the one in `/usr/lib`. Both changes have to go in together
|
would be the one in `/usr/lib`. Both changes have to go in together
|
||||||
* A relative path is taken as it is, tmpfiles.d(5) only has absolute
|
|
||||||
ones
|
|
||||||
+6
-1
@@ -1628,7 +1628,7 @@ static void replace_kind(const char *path, mode_t fmt)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
/* Nothing is removed by a path that may lead somewhere else */
|
/* Nothing is removed by a path that may lead somewhere else */
|
||||||
if (path[0] != '/' || strstr(path, "/./") || strstr(path, "/../"))
|
if (strstr(path, "/./") || strstr(path, "/../"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (size_t len = strlen(copy); len > 1 && copy[len - 1] == '/'; len--)
|
for (size_t len = strlen(copy); len > 1 && copy[len - 1] == '/'; len--)
|
||||||
@@ -1784,6 +1784,11 @@ static void tmpfiles(char *line)
|
|||||||
}
|
}
|
||||||
path = ptr;
|
path = ptr;
|
||||||
}
|
}
|
||||||
|
if (path[0] != '/') {
|
||||||
|
if (!quiet)
|
||||||
|
warnx("Path is not absolute, skipping %s", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (excluded(path))
|
if (excluded(path))
|
||||||
return;
|
return;
|
||||||
if (collect) {
|
if (collect) {
|
||||||
|
|||||||
@@ -95,13 +95,15 @@ f '/tmp/arg/single quote' - - - - single
|
|||||||
f /tmp/arg/mid"dle sp"ace - - - - middle
|
f /tmp/arg/mid"dle sp"ace - - - - middle
|
||||||
f /tmp/arg/esc\x41\sped - - - - "kept as is"
|
f /tmp/arg/esc\x41\sped - - - - "kept as is"
|
||||||
f "/tmp/arg/open - - - - quote
|
f "/tmp/arg/open - - - - quote
|
||||||
|
f tmp/arg/relative - - - - path
|
||||||
CONF
|
CONF
|
||||||
run "/libexec/finit/tmpfiles --create $CONF"
|
run "cd /; /libexec/finit/tmpfiles --create $CONF"
|
||||||
assert "Double quotes" "$(texec cat "$DIR/with space")" = "double"
|
assert "Double quotes" "$(texec cat "$DIR/with space")" = "double"
|
||||||
assert "Single quotes" "$(texec cat "$DIR/single quote")" = "single"
|
assert "Single quotes" "$(texec cat "$DIR/single quote")" = "single"
|
||||||
assert "Quotes in path" "$(texec cat "$DIR/middle space")" = "middle"
|
assert "Quotes in path" "$(texec cat "$DIR/middle space")" = "middle"
|
||||||
assert "Escapes in path" "$(texec cat "$DIR/escA ped")" = '"kept as is"'
|
assert "Escapes in path" "$(texec cat "$DIR/escA ped")" = '"kept as is"'
|
||||||
assert "Skipped with a quote left open" "$(texec sh -c "ls $DIR | grep -c open")" = "0"
|
assert "Skipped with a quote left open" "$(texec sh -c "ls $DIR | grep -c open")" = "0"
|
||||||
|
assert "Skipped when not absolute" "$(texec sh -c "ls $DIR | grep -c relative")" = "0"
|
||||||
|
|
||||||
sep
|
sep
|
||||||
say 'With ~ the argument is Base64'
|
say 'With ~ the argument is Base64'
|
||||||
|
|||||||
Reference in new issue
Block a user