summaryrefslogtreecommitdiff
path: root/src/nspawn
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2019-12-07 12:43:39 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2019-12-12 20:15:10 +0100
commit5530dc87f21c283cb629702cde71f30069e69820 (patch)
treea9afaebd3d12191465397d3b3254b5cfd1f7360c /src/nspawn
parente091a5dfd162822b9ace2a84f127661301b61328 (diff)
downloadsystemd-5530dc87f21c283cb629702cde71f30069e69820.tar.gz
nspawn: Only bind-mount directory when necessary.
Diffstat (limited to 'src/nspawn')
-rw-r--r--src/nspawn/nspawn.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index b85356e1ad..8a55ab20fa 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -3343,13 +3343,6 @@ static int outer_child(
return r;
directory = "/run/systemd/nspawn-root";
-
- } else if (!dissected_image) {
- /* Turn directory into bind mount (we need that so that we can move the bind mount to root
- * later on). */
- r = mount_verbose(LOG_ERR, directory, directory, NULL, MS_BIND|MS_REC, NULL);
- if (r < 0)
- return r;
}
r = setup_pivot_root(
@@ -3377,6 +3370,13 @@ static int outer_child(
if (r < 0)
return r;
+ /* Make sure we always have a mount that we can move to root later on. */
+ if (!path_is_mount_point(directory, NULL, 0)) {
+ r = mount_verbose(LOG_ERR, directory, directory, NULL, MS_BIND|MS_REC, NULL);
+ if (r < 0)
+ return r;
+ }
+
if (dissected_image) {
/* Now we know the uid shift, let's now mount everything else that might be in the image. */
r = dissected_image_mount(dissected_image, directory, arg_uid_shift,