From 97a66e94700845239cfe628da3569ac06034fa4d Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Wed, 16 May 2012 15:08:28 +0200 Subject: [PATCH] main: do_switch_root() do not recursively remove across device boundaries --- src/core/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/main.c b/src/core/main.c index 878eaf35..4d09cb71 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1234,7 +1234,14 @@ static int do_switch_root(const char *switch_root) { } if (cfd >= 0) { - rm_rf_children(cfd, false, false); + struct stat rb; + + if (fstat(cfd, &rb)) { + log_error("failed to stat old root directory"); + goto fail; + } + + rm_rf_children(cfd, false, false, &rb); close(cfd); cfd=-1; } -- 2.39.5