From c19ae2094e865f1a153e25b865315bd68edf075b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 13 Feb 2024 19:54:08 +0100 Subject: [PATCH] Revert "libmount: don't canonicalize symlinks for bind operation" This reverts commit 1b2d8187360157b00b47f52522fc039d82e34e6b. Unfortunately, this new feature introduces a regression. We need a better solution (probably mount options option to enable the feature) rather than enable it by default. Fixes: https://github.com/util-linux/util-linux/issues/2773 References: https://github.com/util-linux/util-linux/issues/2370 --- libmount/src/context_mount.c | 6 +----- sys-utils/mount.8.adoc | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index 9beac17c01..b8302f9fc7 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -674,7 +674,6 @@ static int prepare_target(struct libmnt_context *cxt) const char *tgt, *prefix; int rc = 0; struct libmnt_ns *ns_old; - struct stat st; assert(cxt); assert(cxt->fs); @@ -714,10 +713,7 @@ static int prepare_target(struct libmnt_context *cxt) return -MNT_ERR_NAMESPACE; /* canonicalize the path */ - if (rc == 0 && - !(cxt->optlist && mnt_optlist_is_bind(cxt->optlist) - && mnt_safe_lstat(tgt, &st) == 0 && S_ISLNK(st.st_mode))) { - + if (rc == 0) { struct libmnt_cache *cache = mnt_context_get_cache(cxt); if (cache) { diff --git a/sys-utils/mount.8.adoc b/sys-utils/mount.8.adoc index 1eb2f8ce62..ba8b45a2a2 100644 --- a/sys-utils/mount.8.adoc +++ b/sys-utils/mount.8.adoc @@ -240,8 +240,6 @@ It's also possible to change nosuid, nodev, noexec, noatime, nodiratime, relatim Since util-linux 2.31, *mount* ignores the *bind* flag from _/etc/fstab_ on a *remount* operation (if *-o remount* is specified on command line). This is necessary to fully control mount options on remount by command line. In previous versions the bind flag has been always applied and it was impossible to re-define mount options without interaction with the bind semantic. This *mount* behavior does not affect situations when "remount,bind" is specified in the _/etc/fstab_ file. -Since util-linux 2.40, *mount* does not canonicalize the mountpoint path on bind operation if the target is a symlink. This feature is usable (only) with the new kernel mount API where *bind mount over symlinks* is supported. - === The move operation Move a *mounted tree* to another place (atomically). The call is: @@ -319,9 +317,7 @@ Note that it is a bad practice to use *mount -a* for _fstab_ checking. The recom Remount a subtree somewhere else (so that its contents are available in both places). See above, under *Bind mount operation*. *-c*, *--no-canonicalize*:: -Don't canonicalize paths. The *mount* command canonicalizes all paths (from the command line or _fstab_) by default. The option is designed for mount helpers which call *mount -i*. It is strongly recommended to not use this command-line option for normal mount operations. -+ -Since util-linux 2.40, mount does not canonicalize the mountpoint path on bind operation if the target is a symlink (see "*Bind mount operation*" section for more details). +Don't canonicalize paths. The *mount* command canonicalizes all paths (from the command line or _fstab_) by default. This option can be used together with the *-f* flag for already canonicalized absolute paths. The option is designed for mount helpers which call *mount -i*. It is strongly recommended to not use this command-line option for normal mount operations. + Note that *mount* does not pass this option to the **/sbin/mount.**__type__ helpers. -- 2.47.3