From: Lennart Poettering Date: Wed, 8 Nov 2017 17:35:16 +0000 (+0100) Subject: namespace: set up OS hierarchy only after mounting the new root, not before X-Git-Tag: v236~226^2~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e0c20de9781a9b46e11657b1aff535dd385fa51;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/core/namespace.c b/src/core/namespace.c index 33349f288e1..f1ab6f9736a 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;