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 878eaf353f99106572449b442304476d415400f2..4d09cb71742a54fd20d6d5d53f83c13ccceb26fe 100644 (file)
@@ -1234,7 +1234,14 @@ static int do_switch_root(const char *switch_root) {
         }
 
         if (cfd >= 0) {
         }
 
         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;
         }
                 close(cfd);
                 cfd=-1;
         }