From 84b4c7857098cebce91fc98c61696b19e79ab53f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 May 2023 21:31:38 +0200 Subject: switch-root: add a comment regarding the safety limits of rm_rf_children() --- src/shared/switch-root.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c index fa438b3c06..1ee06c8ee4 100644 --- a/src/shared/switch-root.c +++ b/src/shared/switch-root.c @@ -130,6 +130,8 @@ int switch_root(const char *new_root, if (fstat(old_root_fd, &rb) < 0) return log_error_errno(errno, "Failed to stat old root directory: %m"); + /* Note: the below won't operate on non-memory file systems (i.e. only on tmpfs, ramfs), and + * it will stop at mount boundaries */ (void) rm_rf_children(TAKE_FD(old_root_fd), 0, &rb); /* takes possession of the dir fd, even on failure */ } -- cgit v1.2.1