fix: preserve source ownership in EXDEV symlink fallbacks

This commit is contained in:
Antonio SJ Musumeci 2026-10-28 12:12:38 -05:00 • committed by trapexit
parent 7b7e96bbc5
commit b10fb10590
9 changed files with 473 additions and 166 deletions

View file

@ -12,6 +12,14 @@ the newpath. The target value is determined by the value of
* `link-exdev=abs-pool-symlink`: An absolute value using the mergerfs
mount point.
* Defaults to `passthrough`.
Replacement symlinks retain the source inode's UID and GID, read without
following a source symlink. Relative and pool targets use the first
`getattr`-policy source branch; absolute branch targets use the source
selected by the `open` policy. Creation uses daemon credentials, then
sets the source ownership, rather than using the link request's UID/GID,
which may be invalid when `allow-idmap` is enabled. A newly created
replacement is removed if its ownership cannot be set.
**NOTE:** It is possible that some applications check the file they
link. In those cases, it is possible it will error or complain.

View file

@ -18,6 +18,15 @@ The staging directory is created on demand, including for files at the
pool root. Relative targets are calculated within the pool's relative
path namespace.
Replacement symlinks retain the UID and GID of the first source inode
selected by the rename action policy, read before moving the source and
without following source symlinks. Creation uses daemon credentials,
then sets the source ownership; it does not use the rename request's
UID/GID, which may be invalid when `allow-idmap` is enabled. A newly
created replacement is removed if its ownership cannot be set. If
replacement creation fails, mergerfs attempts to restore the original
source paths.
**NOTE:** It is possible that some applications check the file they
rename. In those cases it is possible it will error or complain.

View file

@ -261,6 +261,12 @@ As of v2.42.0 mergerfs now runs as root more generally. Either
changing credentials when creating files (Linux) or chown'ing them
after creation (FreeBSD).
The optional EXDEV link and rename fallbacks create replacement
symlinks under daemon credentials and then preserve the source inode's
UID and GID. They do not use the link or rename request's UID/GID:
these may be invalid with `allow-idmap`. Ordinary symlink creation
continues to use the creation request's credentials.
As a result of this change it is now necessary for the FUSE
`default_permissions` feature be used for proper entitlements
management. mergerfs does allow it to be disabled but it should only