From 4e0c20de9781a9b46e11657b1aff535dd385fa51 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 8 Nov 2017 18:35:16 +0100 Subject: [PATCH] namespace: set up OS hierarchy only after mounting the new root, not before 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/namespace.c b/src/core/namespace.c index 33349f288e..f1ab6f9736 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -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;