summaryrefslogtreecommitdiff
path: root/src/nspawn/nspawn-mount.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2019-12-06 22:45:14 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2019-12-12 20:15:03 +0100
commit5f0a6347acf0da462cd5ac6d913ffa28e7463ef5 (patch)
treedc7c41639bb8c24cbfe5c6be3ff52d621cebbc14 /src/nspawn/nspawn-mount.c
parent65ca546f0697f7a17bd435abd0d77bec26dbf28e (diff)
downloadsystemd-5f0a6347acf0da462cd5ac6d913ffa28e7463ef5.tar.gz
nspawn: Enable specifying root as the mount target directory.
Fixes #3847.
Diffstat (limited to 'src/nspawn/nspawn-mount.c')
-rw-r--r--src/nspawn/nspawn-mount.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c
index 6407503c4c..8225cf473a 100644
--- a/src/nspawn/nspawn-mount.c
+++ b/src/nspawn/nspawn-mount.c
@@ -222,8 +222,6 @@ int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only)
if (!path_is_absolute(destination))
return -EINVAL;
- if (empty_or_root(destination))
- return -EINVAL;
m = custom_mount_add(l, n, CUSTOM_MOUNT_BIND);
if (!m)
@@ -262,8 +260,6 @@ int tmpfs_mount_parse(CustomMount **l, size_t *n, const char *s) {
if (!path_is_absolute(path))
return -EINVAL;
- if (empty_or_root(path))
- return -EINVAL;
m = custom_mount_add(l, n, CUSTOM_MOUNT_TMPFS);
if (!m)
@@ -323,9 +319,6 @@ int overlay_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_onl
return -EINVAL;
}
- if (empty_or_root(destination))
- return -EINVAL;
-
m = custom_mount_add(l, n, CUSTOM_MOUNT_OVERLAY);
if (!m)
return -ENOMEM;
@@ -923,7 +916,7 @@ int mount_custom(
CustomMount *mounts, size_t n,
bool userns, uid_t uid_shift, uid_t uid_range,
const char *selinux_apifs_context,
- bool in_userns) {
+ MountSettingsMask mount_settings) {
size_t i;
int r;
@@ -933,7 +926,13 @@ int mount_custom(
for (i = 0; i < n; i++) {
CustomMount *m = mounts + i;
- if (m->in_userns != in_userns)
+ if ((mount_settings & MOUNT_IN_USERNS) != m->in_userns)
+ continue;
+
+ if (mount_settings & MOUNT_ROOT_ONLY && !path_equal(m->destination, "/"))
+ continue;
+
+ if (mount_settings & MOUNT_NON_ROOT_ONLY && path_equal(m->destination, "/"))
continue;
switch (m->type) {