[ostree] prepare-root: Only bind mount /home, /tmp, /root if they are directories



commit f6946a368fb82df76844a9ea7d027dc691a7a19a
Author: Colin Walters <walters verbum org>
Date:   Sun Jun 23 17:56:14 2013 -0400

    prepare-root: Only bind mount /home, /tmp, /root if they are directories
    
    What we expect for new systems is for these to be symbolic links:
    /home -> /sysroot/home
    etc.

 src/switchroot/ostree-prepare-root.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c
index e16d79e..cfd7481 100644
--- a/src/switchroot/ostree-prepare-root.c
+++ b/src/switchroot/ostree-prepare-root.c
@@ -180,10 +180,16 @@ main(int argc, char *argv[])
     {
       snprintf (srcpath, sizeof(srcpath), "%s%s", root_mountpoint, toproot_bind_mounts[i]);
       snprintf (destpath, sizeof(destpath), "%s%s", deploy_path, toproot_bind_mounts[i]);
-      if (mount (srcpath, destpath, NULL, MS_BIND & ~MS_RDONLY, NULL) < 0)
+      /* Only do these bind mounts if the target exists and is a real directory,
+       * not a symbolic link.
+       */
+      if (lstat (destpath, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))
        {
-         perrorv ("failed to bind mount (class:toproot) %s to %s", toproot_bind_mounts[i], destpath);
-         exit (1);
+         if (mount (srcpath, destpath, NULL, MS_BIND & ~MS_RDONLY, NULL) < 0)
+           {
+             perrorv ("failed to bind mount (class:toproot) %s to %s", toproot_bind_mounts[i], destpath);
+             exit (1);
+           }
        }
     }
 


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