]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
namespace: set up OS hierarchy only after mounting the new root, not before
authorLennart Poettering <lennart@poettering.net>
Wed, 8 Nov 2017 17:35:16 +0000 (18:35 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 13 Nov 2017 09:22:36 +0000 (10:22 +0100)
Otherwise it's a pointless excercise, as we'll set up an empty directory
tree that's never going to be used.

Hence, let's move this around a bit, so that we do the basesystem
initialization exactly when RootImage= or RootDirectory= are used, but
not otherwise.

src/core/namespace.c

index 33349f288e1f7de2ed9f919645679a2e681799d5..f1ab6f9736a6d1a311f61158cf319f8fbe65218d 100644 (file)
@@ -1152,10 +1152,6 @@ int setup_namespace(
                 }
         }
 
-        /* Try to set up the new root directory before mounting anything there */
-        if (root)
-                (void) base_filesystem_create(root, UID_INVALID, GID_INVALID);
-
         if (root_image) {
                 /* A root image is specified, mount it to the right place */
                 r = dissected_image_mount(dissected_image, root, dissect_image_flags);
@@ -1192,6 +1188,10 @@ int setup_namespace(
                 }
         }
 
+        /* Try to set up the new root directory before mounting anything else there. */
+        if (root_image || root_directory)
+                (void) base_filesystem_create(root, UID_INVALID, GID_INVALID);
+
         if (n_mounts > 0) {
                 _cleanup_fclose_ FILE *proc_self_mountinfo = NULL;
                 char **blacklist;