summaryrefslogtreecommitdiff
path: root/src/shared/mount-util.c
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2022-04-06 17:25:35 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2022-04-07 17:31:04 +0100
commitcedf5b1aef4da2443f00eef2c242c8b005071aca (patch)
tree519a992b7d3ad13df2ac98b968238d8829552053 /src/shared/mount-util.c
parent1e582ede3b04d12aae11fc5378a446a392054f1c (diff)
downloadsystemd-cedf5b1aef4da2443f00eef2c242c8b005071aca.tar.gz
core: fix dm-verity auto-discovery in MountImageUnit()
The implementation of MountImageUnit()/systemctl mount-image was changed to use a /proc/self/fd path as the source, but that causes the dm-verity files autodiscovery to fail, as it looks for files in the same directory as the image. Use the original file path when setting up dm-verity.
Diffstat (limited to 'src/shared/mount-util.c')
-rw-r--r--src/shared/mount-util.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c
index 78f06b25fe..e76e4a0b38 100644
--- a/src/shared/mount-util.c
+++ b/src/shared/mount-util.c
@@ -789,6 +789,7 @@ static int mount_in_namespace(
bool mount_slave_created = false, mount_slave_mounted = false,
mount_tmp_created = false, mount_tmp_mounted = false,
mount_outside_created = false, mount_outside_mounted = false;
+ _cleanup_free_ char *chased_src_path = NULL;
struct stat st, self_mntns_st;
pid_t child;
int r;
@@ -826,9 +827,10 @@ static int mount_in_namespace(
if (r < 0)
return log_debug_errno(r == -ENOENT ? SYNTHETIC_ERRNO(EOPNOTSUPP) : r, "Target does not allow propagation of mount points");
- r = chase_symlinks(src, NULL, CHASE_TRAIL_SLASH, NULL, &chased_src_fd);
+ r = chase_symlinks(src, NULL, 0, &chased_src_path, &chased_src_fd);
if (r < 0)
return log_debug_errno(r, "Failed to resolve source path of %s: %m", src);
+ log_debug("Chased source path of %s to %s", src, chased_src_path);
if (fstat(chased_src_fd, &st) < 0)
return log_debug_errno(errno, "Failed to stat() resolved source path %s: %m", src);
@@ -873,7 +875,7 @@ static int mount_in_namespace(
mount_tmp_created = true;
if (is_image)
- r = verity_dissect_and_mount(FORMAT_PROC_FD_PATH(chased_src_fd), mount_tmp, options, NULL, NULL, NULL, NULL);
+ r = verity_dissect_and_mount(chased_src_fd, chased_src_path, mount_tmp, options, NULL, NULL, NULL, NULL);
else
r = mount_follow_verbose(LOG_DEBUG, FORMAT_PROC_FD_PATH(chased_src_fd), mount_tmp, NULL, MS_BIND, NULL);
if (r < 0)