Skip to content

Commit 659218a

Browse files
committed
tmpfiles: Don't traverse mount points
For the same reason we avoid doing this in other code like in lints.rs; it's reasonable for someone to mount a volume on `/var/cache/dnf` for example in a container build, and we don't want to try to convert it to tmpfiles.d. Signed-off-by: Colin Walters <[email protected]>
1 parent eb55216 commit 659218a

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

tmpfiles/src/lib.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -337,20 +337,24 @@ fn convert_path_to_tmpfiles_d_recurse<U: uzers::Users, G: uzers::Groups>(
337337
}
338338

339339
if meta.is_dir() {
340-
convert_path_to_tmpfiles_d_recurse(
341-
out_entries,
342-
out_unsupported,
343-
users,
344-
groups,
345-
rootfs,
346-
existing,
347-
prefix,
348-
readonly,
349-
)?;
350340
// SAFETY: We know this path is absolute
351341
let relpath = prefix.strip_prefix("/").unwrap();
352-
if !readonly {
353-
rootfs.remove_dir_all(relpath)?;
342+
// Avoid traversing mount points by default
343+
if rootfs.open_dir_noxdev(relpath)?.is_some() {
344+
convert_path_to_tmpfiles_d_recurse(
345+
out_entries,
346+
out_unsupported,
347+
users,
348+
groups,
349+
rootfs,
350+
existing,
351+
prefix,
352+
readonly,
353+
)?;
354+
let relpath = prefix.strip_prefix("/").unwrap();
355+
if !readonly {
356+
rootfs.remove_dir_all(relpath)?;
357+
}
354358
}
355359
} else {
356360
// SAFETY: We know this path is absolute

0 commit comments

Comments
 (0)