[linux-user-chroot] Only MS_MOVE the root to / if the root isn't already /



commit 61eea63b4042d1c6fba12d79215f5b9247d3b5c5
Author: Colin Walters <walters verbum org>
Date:   Thu Jan 10 14:25:37 2013 -0500

    Only MS_MOVE the root to / if the root isn't already /
    
    Otherwise the MS_MOVE call aborts.

 src/linux-user-chroot.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/linux-user-chroot.c b/src/linux-user-chroot.c
index 82070b2..fa8a2be 100644
--- a/src/linux-user-chroot.c
+++ b/src/linux-user-chroot.c
@@ -351,11 +351,15 @@ main (int      argc,
       if (mount (chroot_dir, chroot_dir, NULL, MS_BIND | MS_PRIVATE, NULL) < 0)
         fatal_errno ("mount (MS_BIND)");
 
-      if (mount (chroot_dir, "/", NULL, MS_MOVE, NULL) < 0)
-        fatal_errno ("mount (MS_MOVE)");
+      /* Only move if we're not actually just using / */
+      if (strcmp (chroot_dir, "/") != 0)
+        {
+          if (mount (chroot_dir, "/", NULL, MS_MOVE, NULL) < 0)
+            fatal_errno ("mount (MS_MOVE)");
 
-      if (chroot (".") < 0)
-        fatal_errno ("chroot");
+          if (chroot (".") < 0)
+            fatal_errno ("chroot");
+        }
       
       if (chdir (chdir_target) < 0)
         fatal_errno ("chdir");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]