mount-util: switch most mount_verbose() code over to not follow symlinks
This commit is contained in:
+19
-19
@@ -105,11 +105,11 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t uid_shift) {
|
||||
return log_error_errno(errno, "Failed to generate temporary mount point for unified hierarchy: %m");
|
||||
|
||||
if (unified_controller > 0)
|
||||
r = mount_verbose(LOG_ERR, "cgroup", tree, "cgroup",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV, "none,name=systemd,xattr");
|
||||
r = mount_nofollow_verbose(LOG_ERR, "cgroup", tree, "cgroup",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV, "none,name=systemd,xattr");
|
||||
else
|
||||
r = mount_verbose(LOG_ERR, "cgroup", tree, "cgroup2",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "cgroup", tree, "cgroup2",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
||||
@@ -275,14 +275,14 @@ static int mount_legacy_cgroup_hierarchy(
|
||||
opts = controller;
|
||||
}
|
||||
|
||||
r = mount_verbose(LOG_ERR, "cgroup", to, fstype, MS_NOSUID|MS_NOEXEC|MS_NODEV, opts);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "cgroup", to, fstype, MS_NOSUID|MS_NOEXEC|MS_NODEV, opts);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* ... hence let's only make the bind mount read-only, not the superblock. */
|
||||
if (read_only) {
|
||||
r = mount_verbose(LOG_ERR, NULL, to, NULL,
|
||||
MS_BIND|MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, NULL, to, NULL,
|
||||
MS_BIND|MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -323,8 +323,8 @@ static int mount_legacy_cgns_supported(
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
r = mount_verbose(LOG_ERR, "tmpfs", cgroup_root, "tmpfs",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME, options);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "tmpfs", cgroup_root, "tmpfs",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME, options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -391,8 +391,8 @@ skip_controllers:
|
||||
return r;
|
||||
|
||||
if (!userns)
|
||||
return mount_verbose(LOG_ERR, NULL, cgroup_root, NULL,
|
||||
MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME|MS_RDONLY, "mode=755");
|
||||
return mount_nofollow_verbose(LOG_ERR, NULL, cgroup_root, NULL,
|
||||
MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME|MS_RDONLY, "mode=755");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -425,8 +425,8 @@ static int mount_legacy_cgns_unsupported(
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
r = mount_verbose(LOG_ERR, "tmpfs", cgroup_root, "tmpfs",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME, options);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "tmpfs", cgroup_root, "tmpfs",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME, options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -499,8 +499,8 @@ skip_controllers:
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return mount_verbose(LOG_ERR, NULL, cgroup_root, NULL,
|
||||
MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME|MS_RDONLY, "mode=755");
|
||||
return mount_nofollow_verbose(LOG_ERR, NULL, cgroup_root, NULL,
|
||||
MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME|MS_RDONLY, "mode=755");
|
||||
}
|
||||
|
||||
static int mount_unified_cgroups(const char *dest) {
|
||||
@@ -527,7 +527,7 @@ static int mount_unified_cgroups(const char *dest) {
|
||||
"%s is already mounted but not a unified cgroup hierarchy. Refusing.", p);
|
||||
}
|
||||
|
||||
return mount_verbose(LOG_ERR, "cgroup", p, "cgroup2", MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
|
||||
return mount_nofollow_verbose(LOG_ERR, "cgroup", p, "cgroup2", MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
|
||||
}
|
||||
|
||||
int mount_cgroups(
|
||||
@@ -554,13 +554,13 @@ static int mount_systemd_cgroup_writable_one(const char *root, const char *own)
|
||||
assert(own);
|
||||
|
||||
/* Make our own cgroup a (writable) bind mount */
|
||||
r = mount_verbose(LOG_ERR, own, own, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, own, own, NULL, MS_BIND, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* And then remount the systemd cgroup root read-only */
|
||||
return mount_verbose(LOG_ERR, NULL, root, NULL,
|
||||
MS_BIND|MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, NULL);
|
||||
return mount_nofollow_verbose(LOG_ERR, NULL, root, NULL,
|
||||
MS_BIND|MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, NULL);
|
||||
}
|
||||
|
||||
int mount_systemd_cgroup_writable(
|
||||
|
||||
+36
-32
@@ -40,7 +40,9 @@ CustomMount* custom_mount_add(CustomMount **l, size_t *n, CustomMountType t) {
|
||||
ret = *l + *n;
|
||||
(*n)++;
|
||||
|
||||
*ret = (CustomMount) { .type = t };
|
||||
*ret = (CustomMount) {
|
||||
.type = t
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -442,8 +444,8 @@ int mount_sysfs(const char *dest, MountSettingsMask mount_settings) {
|
||||
if (FLAGS_SET(mount_settings, MOUNT_APPLY_APIVFS_RO))
|
||||
extra_flags |= MS_RDONLY;
|
||||
|
||||
r = mount_verbose(LOG_ERR, "sysfs", full, "sysfs",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV|extra_flags, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "sysfs", full, "sysfs",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV|extra_flags, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -460,12 +462,12 @@ int mount_sysfs(const char *dest, MountSettingsMask mount_settings) {
|
||||
|
||||
(void) mkdir(to, 0755);
|
||||
|
||||
r = mount_verbose(LOG_ERR, from, to, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, from, to, NULL, MS_BIND, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = mount_verbose(LOG_ERR, NULL, to, NULL,
|
||||
MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT|extra_flags, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, NULL, to, NULL,
|
||||
MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT|extra_flags, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -483,8 +485,8 @@ int mount_sysfs(const char *dest, MountSettingsMask mount_settings) {
|
||||
x = prefix_roota(top, "/fs/cgroup");
|
||||
(void) mkdir_p(x, 0755);
|
||||
|
||||
return mount_verbose(LOG_ERR, NULL, top, NULL,
|
||||
MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT|extra_flags, NULL);
|
||||
return mount_nofollow_verbose(LOG_ERR, NULL, top, NULL,
|
||||
MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT|extra_flags, NULL);
|
||||
}
|
||||
|
||||
int mount_all(const char *dest,
|
||||
@@ -516,7 +518,7 @@ int mount_all(const char *dest,
|
||||
static const MountPoint mount_table[] = {
|
||||
/* First we list inner child mounts (i.e. mounts applied *after* entering user namespacing) */
|
||||
{ "proc", "/proc", "proc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||
MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_MKDIR },
|
||||
MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_MKDIR|MOUNT_FOLLOW_SYMLINKS }, /* we follow symlinks here since not following them requires /proc/ already being mounted, which we don't have here. */
|
||||
|
||||
{ "/proc/sys", "/proc/sys", NULL, NULL, MS_BIND,
|
||||
MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO }, /* Bind mount first ... */
|
||||
@@ -670,12 +672,14 @@ int mount_all(const char *dest,
|
||||
return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, mount_table[k].what);
|
||||
}
|
||||
|
||||
r = mount_verbose(fatal ? LOG_ERR : LOG_DEBUG,
|
||||
prefixed ?: mount_table[k].what,
|
||||
where,
|
||||
mount_table[k].type,
|
||||
mount_table[k].flags,
|
||||
o);
|
||||
r = mount_verbose_full(
|
||||
fatal ? LOG_ERR : LOG_DEBUG,
|
||||
prefixed ?: mount_table[k].what,
|
||||
where,
|
||||
mount_table[k].type,
|
||||
mount_table[k].flags,
|
||||
o,
|
||||
FLAGS_SET(mount_table[k].mount_settings, MOUNT_FOLLOW_SYMLINKS));
|
||||
if (r < 0 && fatal)
|
||||
return r;
|
||||
}
|
||||
@@ -771,7 +775,7 @@ static int mount_bind(const char *dest, CustomMount *m) {
|
||||
return log_error_errno(r, "Failed to create mount point %s: %m", where);
|
||||
}
|
||||
|
||||
r = mount_verbose(LOG_ERR, m->source, where, NULL, mount_flags, mount_opts);
|
||||
r = mount_nofollow_verbose(LOG_ERR, m->source, where, NULL, mount_flags, mount_opts);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -807,7 +811,7 @@ static int mount_tmpfs(const char *dest, CustomMount *m, uid_t uid_shift, const
|
||||
return log_oom();
|
||||
options = r > 0 ? buf : m->options;
|
||||
|
||||
return mount_verbose(LOG_ERR, "tmpfs", where, "tmpfs", MS_NODEV|MS_STRICTATIME, options);
|
||||
return mount_nofollow_verbose(LOG_ERR, "tmpfs", where, "tmpfs", MS_NODEV|MS_STRICTATIME, options);
|
||||
}
|
||||
|
||||
static char *joined_and_escaped_lower_dirs(char **lower) {
|
||||
@@ -864,7 +868,7 @@ static int mount_overlay(const char *dest, CustomMount *m) {
|
||||
options = strjoina("lowerdir=", lower, ",upperdir=", escaped_source, ",workdir=", escaped_work_dir);
|
||||
}
|
||||
|
||||
return mount_verbose(LOG_ERR, "overlay", where, "overlay", m->read_only ? MS_RDONLY : 0, options);
|
||||
return mount_nofollow_verbose(LOG_ERR, "overlay", where, "overlay", m->read_only ? MS_RDONLY : 0, options);
|
||||
}
|
||||
|
||||
static int mount_inaccessible(const char *dest, CustomMount *m) {
|
||||
@@ -885,11 +889,11 @@ static int mount_inaccessible(const char *dest, CustomMount *m) {
|
||||
if (r < 0)
|
||||
return m->graceful ? 0 : r;
|
||||
|
||||
r = mount_verbose(m->graceful ? LOG_DEBUG : LOG_ERR, source, where, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(m->graceful ? LOG_DEBUG : LOG_ERR, source, where, NULL, MS_BIND, NULL);
|
||||
if (r < 0)
|
||||
return m->graceful ? 0 : r;
|
||||
|
||||
r = mount_verbose(m->graceful ? LOG_DEBUG : LOG_ERR, NULL, where, NULL, MS_BIND|MS_RDONLY|MS_REMOUNT, NULL);
|
||||
r = mount_nofollow_verbose(m->graceful ? LOG_DEBUG : LOG_ERR, NULL, where, NULL, MS_BIND|MS_RDONLY|MS_REMOUNT, NULL);
|
||||
if (r < 0) {
|
||||
(void) umount_verbose(where);
|
||||
return m->graceful ? 0 : r;
|
||||
@@ -914,7 +918,7 @@ static int mount_arbitrary(const char *dest, CustomMount *m) {
|
||||
return log_error_errno(r, "Creating mount point for mount %s failed: %m", where);
|
||||
}
|
||||
|
||||
return mount_verbose(LOG_ERR, m->source, where, m->type_argument, 0, m->options);
|
||||
return mount_nofollow_verbose(LOG_ERR, m->source, where, m->type_argument, 0, m->options);
|
||||
}
|
||||
|
||||
int mount_custom(
|
||||
@@ -1013,7 +1017,7 @@ static int setup_volatile_state(const char *directory, uid_t uid_shift, const ch
|
||||
if (r > 0)
|
||||
options = buf;
|
||||
|
||||
return mount_verbose(LOG_ERR, "tmpfs", p, "tmpfs", MS_STRICTATIME, options);
|
||||
return mount_nofollow_verbose(LOG_ERR, "tmpfs", p, "tmpfs", MS_STRICTATIME, options);
|
||||
}
|
||||
|
||||
static int setup_volatile_yes(const char *directory, uid_t uid_shift, const char *selinux_apifs_context) {
|
||||
@@ -1058,7 +1062,7 @@ static int setup_volatile_yes(const char *directory, uid_t uid_shift, const char
|
||||
if (r > 0)
|
||||
options = buf;
|
||||
|
||||
r = mount_verbose(LOG_ERR, "tmpfs", template, "tmpfs", MS_STRICTATIME, options);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "tmpfs", template, "tmpfs", MS_STRICTATIME, options);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
@@ -1073,7 +1077,7 @@ static int setup_volatile_yes(const char *directory, uid_t uid_shift, const char
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = mount_verbose(LOG_ERR, f, t, NULL, MS_BIND|MS_REC, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, f, t, NULL, MS_BIND|MS_REC, NULL);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
@@ -1085,7 +1089,7 @@ static int setup_volatile_yes(const char *directory, uid_t uid_shift, const char
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = mount_verbose(LOG_ERR, template, directory, NULL, MS_MOVE, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, template, directory, NULL, MS_MOVE, NULL);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
@@ -1125,7 +1129,7 @@ static int setup_volatile_overlay(const char *directory, uid_t uid_shift, const
|
||||
if (r > 0)
|
||||
options = buf;
|
||||
|
||||
r = mount_verbose(LOG_ERR, "tmpfs", template, "tmpfs", MS_STRICTATIME, options);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "tmpfs", template, "tmpfs", MS_STRICTATIME, options);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
||||
@@ -1155,7 +1159,7 @@ static int setup_volatile_overlay(const char *directory, uid_t uid_shift, const
|
||||
}
|
||||
|
||||
options = strjoina("lowerdir=", escaped_directory, ",upperdir=", escaped_upper, ",workdir=", escaped_work);
|
||||
r = mount_verbose(LOG_ERR, "overlay", directory, "overlay", 0, options);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "overlay", directory, "overlay", 0, options);
|
||||
|
||||
finish:
|
||||
if (tmpfs_mounted)
|
||||
@@ -1265,7 +1269,7 @@ int setup_pivot_root(const char *directory, const char *pivot_root_new, const ch
|
||||
return log_oom();
|
||||
|
||||
/* Remount directory_pivot_root_new to make it movable. */
|
||||
r = mount_verbose(LOG_ERR, directory_pivot_root_new, directory_pivot_root_new, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, directory_pivot_root_new, directory_pivot_root_new, NULL, MS_BIND, NULL);
|
||||
if (r < 0)
|
||||
goto done;
|
||||
|
||||
@@ -1282,19 +1286,19 @@ int setup_pivot_root(const char *directory, const char *pivot_root_new, const ch
|
||||
goto done;
|
||||
}
|
||||
|
||||
r = mount_verbose(LOG_ERR, directory_pivot_root_new, pivot_tmp, NULL, MS_MOVE, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, directory_pivot_root_new, pivot_tmp, NULL, MS_MOVE, NULL);
|
||||
if (r < 0)
|
||||
goto done;
|
||||
|
||||
r = mount_verbose(LOG_ERR, directory, pivot_tmp_pivot_root_old, NULL, MS_MOVE, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, directory, pivot_tmp_pivot_root_old, NULL, MS_MOVE, NULL);
|
||||
if (r < 0)
|
||||
goto done;
|
||||
|
||||
r = mount_verbose(LOG_ERR, pivot_tmp, directory, NULL, MS_MOVE, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, pivot_tmp, directory, NULL, MS_MOVE, NULL);
|
||||
if (r < 0)
|
||||
goto done;
|
||||
} else {
|
||||
r = mount_verbose(LOG_ERR, directory_pivot_root_new, directory, NULL, MS_MOVE, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, directory_pivot_root_new, directory, NULL, MS_MOVE, NULL);
|
||||
if (r < 0)
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ typedef enum MountSettingsMask {
|
||||
MOUNT_MKDIR = 1 << 8, /* if set, make directory to mount over first */
|
||||
MOUNT_TOUCH = 1 << 9, /* if set, touch file to mount over first */
|
||||
MOUNT_PREFIX_ROOT = 1 << 10,/* if set, prefix the source path with the container's root directory */
|
||||
MOUNT_FOLLOW_SYMLINKS = 1 << 11,/* if set, we'll follow symlinks for the mount target */
|
||||
} MountSettingsMask;
|
||||
|
||||
typedef enum CustomMountType {
|
||||
|
||||
+21
-21
@@ -1918,9 +1918,9 @@ static int setup_timezone(const char *dest) {
|
||||
if (found == 0) /* missing? */
|
||||
(void) touch(resolved);
|
||||
|
||||
r = mount_verbose(LOG_WARNING, "/etc/localtime", resolved, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_WARNING, "/etc/localtime", resolved, NULL, MS_BIND, NULL);
|
||||
if (r >= 0)
|
||||
return mount_verbose(LOG_ERR, NULL, resolved, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_NOSUID|MS_NODEV, NULL);
|
||||
return mount_nofollow_verbose(LOG_ERR, NULL, resolved, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_NOSUID|MS_NODEV, NULL);
|
||||
|
||||
_fallthrough_;
|
||||
}
|
||||
@@ -2053,9 +2053,9 @@ static int setup_resolv_conf(const char *dest) {
|
||||
if (found == 0) /* missing? */
|
||||
(void) touch(resolved);
|
||||
|
||||
r = mount_verbose(LOG_WARNING, what, resolved, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_WARNING, what, resolved, NULL, MS_BIND, NULL);
|
||||
if (r >= 0)
|
||||
return mount_verbose(LOG_ERR, NULL, resolved, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_NOSUID|MS_NODEV, NULL);
|
||||
return mount_nofollow_verbose(LOG_ERR, NULL, resolved, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_NOSUID|MS_NODEV, NULL);
|
||||
|
||||
/* If that didn't work, let's copy the file */
|
||||
}
|
||||
@@ -2107,11 +2107,11 @@ static int setup_boot_id(void) {
|
||||
from = TAKE_PTR(path);
|
||||
to = "/proc/sys/kernel/random/boot_id";
|
||||
|
||||
r = mount_verbose(LOG_ERR, from, to, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, from, to, NULL, MS_BIND, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return mount_verbose(LOG_ERR, NULL, to, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
|
||||
return mount_nofollow_verbose(LOG_ERR, NULL, to, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
|
||||
}
|
||||
|
||||
static int copy_devnodes(const char *dest) {
|
||||
@@ -2170,7 +2170,7 @@ static int copy_devnodes(const char *dest) {
|
||||
r = touch(to);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "touch (%s) failed: %m", to);
|
||||
r = mount_verbose(LOG_DEBUG, from, to, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_DEBUG, from, to, NULL, MS_BIND, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Both mknod and bind mount (%s) failed: %m", to);
|
||||
}
|
||||
@@ -2258,7 +2258,7 @@ static int setup_pts(const char *dest) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create /dev/pts: %m");
|
||||
|
||||
r = mount_verbose(LOG_ERR, "devpts", p, "devpts", MS_NOSUID|MS_NOEXEC, options);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "devpts", p, "devpts", MS_NOSUID|MS_NOEXEC, options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = userns_lchown(p, 0, 0);
|
||||
@@ -2360,7 +2360,7 @@ static int setup_credentials(const char *root) {
|
||||
return log_error_errno(r, "Failed to create /run/host/credentials: %m");
|
||||
|
||||
q = prefix_roota(root, "/run/host/credentials");
|
||||
r = mount_verbose(LOG_ERR, NULL, q, "ramfs", MS_NOSUID|MS_NOEXEC|MS_NODEV, "mode=0700");
|
||||
r = mount_nofollow_verbose(LOG_ERR, NULL, q, "ramfs", MS_NOSUID|MS_NOEXEC|MS_NODEV, "mode=0700");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -2397,11 +2397,11 @@ static int setup_credentials(const char *root) {
|
||||
return r;
|
||||
|
||||
/* Make both mount and superblock read-only now */
|
||||
r = mount_verbose(LOG_ERR, NULL, q, NULL, MS_REMOUNT|MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, NULL, q, NULL, MS_REMOUNT|MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return mount_verbose(LOG_ERR, NULL, q, NULL, MS_REMOUNT|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV, "mode=0500");
|
||||
return mount_nofollow_verbose(LOG_ERR, NULL, q, NULL, MS_REMOUNT|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV, "mode=0500");
|
||||
}
|
||||
|
||||
static int setup_kmsg(int kmsg_socket) {
|
||||
@@ -2429,7 +2429,7 @@ static int setup_kmsg(int kmsg_socket) {
|
||||
|
||||
from = TAKE_PTR(fifo);
|
||||
|
||||
r = mount_verbose(LOG_ERR, from, "/proc/kmsg", NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, from, "/proc/kmsg", NULL, MS_BIND, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -2595,7 +2595,7 @@ static int setup_journal(const char *directory) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create %s: %m", q);
|
||||
|
||||
r = mount_verbose(LOG_DEBUG, p, q, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_DEBUG, p, q, NULL, MS_BIND, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "Failed to bind mount journal from host into guest: %m");
|
||||
|
||||
@@ -2700,16 +2700,16 @@ static int setup_propagate(const char *root) {
|
||||
return log_error_errno(r, "Failed to create /run/host/incoming: %m");
|
||||
|
||||
q = prefix_roota(root, "/run/host/incoming");
|
||||
r = mount_verbose(LOG_ERR, p, q, NULL, MS_BIND, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, p, q, NULL, MS_BIND, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = mount_verbose(LOG_ERR, NULL, q, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, NULL, q, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* machined will MS_MOVE into that directory, and that's only supported for non-shared mounts. */
|
||||
return mount_verbose(LOG_ERR, NULL, q, NULL, MS_SLAVE, NULL);
|
||||
return mount_nofollow_verbose(LOG_ERR, NULL, q, NULL, MS_SLAVE, NULL);
|
||||
}
|
||||
|
||||
static int setup_machine_id(const char *directory) {
|
||||
@@ -3157,7 +3157,7 @@ static int inner_child(
|
||||
/* Creating a new user namespace means all MS_SHARED mounts become MS_SLAVE. Let's put them
|
||||
* back to MS_SHARED here, since that's what we want as defaults. (This will not reconnect
|
||||
* propagation, but simply create new peer groups for all our mounts). */
|
||||
r = mount_verbose(LOG_ERR, NULL, "/", NULL, MS_SHARED|MS_REC, NULL);
|
||||
r = mount_follow_verbose(LOG_ERR, NULL, "/", NULL, MS_SHARED|MS_REC, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -3542,7 +3542,7 @@ static int outer_child(
|
||||
|
||||
/* Mark everything as slave, so that we still receive mounts from the real root, but don't propagate
|
||||
* mounts to the real root. */
|
||||
r = mount_verbose(LOG_ERR, NULL, "/", NULL, MS_SLAVE|MS_REC, NULL);
|
||||
r = mount_follow_verbose(LOG_ERR, NULL, "/", NULL, MS_SLAVE|MS_REC, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -3600,7 +3600,7 @@ static int outer_child(
|
||||
* already, and thus don't need to be afraid of colliding with anyone else's mounts).*/
|
||||
(void) mkdir_p("/run/systemd/nspawn-root", 0755);
|
||||
|
||||
r = mount_verbose(LOG_ERR, "/", "/run/systemd/nspawn-root", NULL, MS_BIND|MS_REC, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, "/", "/run/systemd/nspawn-root", NULL, MS_BIND|MS_REC, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -3634,7 +3634,7 @@ static int outer_child(
|
||||
|
||||
/* 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);
|
||||
r = mount_nofollow_verbose(LOG_ERR, directory, directory, NULL, MS_BIND|MS_REC, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -3677,7 +3677,7 @@ static int outer_child(
|
||||
* enable moving the root directory mount to root later on.
|
||||
* https://github.com/systemd/systemd/issues/3847#issuecomment-562735251
|
||||
*/
|
||||
r = mount_verbose(LOG_ERR, NULL, directory, NULL, MS_SHARED|MS_REC, NULL);
|
||||
r = mount_nofollow_verbose(LOG_ERR, NULL, directory, NULL, MS_SHARED|MS_REC, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user