containers / fuse-overlayfs

FUSE implementation for overlayfs
GNU General Public License v2.0
502 stars 83 forks source link

Failure to replace a file that is non-writable in lower dir #377

Open ydirson opened 1 year ago

ydirson commented 1 year ago

Context: trying to remaster an ISO by just fuse-mounting and modifying the overlay to generate a new ISO, without doing useless file copies. fuseiso gives me a filesystem where all files appear as readonly (and even owned by root).

There should be no reason to be unable to replace such a file in an overlay, but something seems to just prevent it:

$ mkdir lower upper work merged
$ touch lower/foo lower/bar
$ chmod -w lower/bar 
$ fuse-overlayfs -o lowerdir=lower,upperdir=upper,workdir=work merged/
$ mv merged/foo merged/foo0
$ mv merged/bar merged/bar0
mv: cannot move 'merged/bar' to 'merged/bar0': Permission denied
$ rm merged/bar 
rm: remove write-protected regular empty file 'merged/bar'? y
rm: cannot remove 'merged/bar': Permission denied
$ echo "new contents" > merged/bar 
bash: merged/bar: Permission denied

This can be worked around by adding updated files manually in upper dir, but it kinda defeats the purpose in the general case :)

winnscode commented 1 year ago

can't reproduce in my enviroment

$ fuse-overlayfs --version fuse-overlayfs: version 1.10 FUSE library version 3.13.0 using FUSE kernel interface version 7.38 fusermount3 version: 3.13.0

MartinLoeper commented 11 months ago

Just noticed the same in the case where I tried to mount an overlayfs from user space onto the nix store in NixOS which is read-only by default.

As a workaround, I run the filesystem as root. I wonder why this is necessary in the current implementation. Definitely unexpected behaviour imo.