mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: skip a C entry with a relative path to copy from
The argument of a C entry was used as it is, so a relative one was
copied from the directory tmpfiles happened to be started in. With
--root that directory is outside the new root, and
C /etc/copy - - - - ../../../etc/shadow
in a file below the root copied a file of the running system into it.
systemd skips a C line when the path to copy from is not absolute.
Do the same, with a warning.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
3 files changed
+9
No files matched your search
@@ -375,6 +375,9 @@ All relevant changes are documented in this file.
|
||||
- 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 tmpfiles `C` entries with a relative path to copy from, it was
|
||||
taken from 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
|
||||
files installed. They create `/run/nologin` at boot, and on systemd it
|
||||
is removed by systemd-user-sessions. Finit now removes it when leaving
|
||||
|
||||
@@ -2001,6 +2001,10 @@ static int parse(char *line)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (e.type[0] == 'C' && e.arg && e.arg[0] != '/') {
|
||||
warnx("Path to copy from is not absolute, skipping %s", e.path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (e.path == pathbuf)
|
||||
e.path = xpath = strdup(pathbuf);
|
||||
|
||||
@@ -34,6 +34,7 @@ z /var/lib/root-test/other 0644
|
||||
L /link - - - - /var/lib/root-test
|
||||
f /link/through 0640
|
||||
C /etc/issue
|
||||
C /etc/outside - - - - ../../../etc/passwd
|
||||
d /skipped 0700 daemon
|
||||
CONF
|
||||
run "echo 'd /from/cmdline 0711' > $CONF"
|
||||
@@ -55,6 +56,7 @@ say 'So are the paths, also what a link points to'
|
||||
assert_stat /var/lib/root-test/other "644 0 0"
|
||||
assert_stat /var/lib/root-test/through "640 0 0"
|
||||
assert "Copied from its factory" "$(texec cat $ROOT/etc/issue)" = "factory"
|
||||
assert "No copy from outside it" "$(texec sh -c "ls $ROOT/etc | grep -c outside")" = "0"
|
||||
assert "Nothing outside it" "$(texec sh -c "ls /var/lib | grep -c root-test")" = "0"
|
||||
|
||||
sep
|
||||
|
||||
Reference in new issue
Block a user