chiark / gitweb /
main: do_switch_root() do not recursively remove across device boundaries
authorHarald Hoyer <harald@redhat.com>
Wed, 16 May 2012 13:08:28 +0000 (15:08 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 21 May 2012 16:53:02 +0000 (18:53 +0200)
src/core/main.c

index 878eaf3..4d09cb7 100644 (file)
@@ -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;
         }