graysky2 / profile-sync-daemon

Symlinks and syncs browser profile dirs to RAM thus reducing HDD/SDD calls and speeding-up browsers.
https://wiki.archlinux.org/index.php/Profile-sync-daemon
Other
899 stars 84 forks source link

rm: cannot remove '/run/user/1000/.../index': Permission denied #285

Closed Szunti closed 3 years ago

Szunti commented 3 years ago

The message was in the journal after systemctl --user stop psd.service After that systemctl --user start psd.service failed with:

 profile-sync-daemon[2234]: Error in trying to mount /run/user/1000/... - this should not happen!
systemd[475]: psd-resync.service: Main process exited, code=exited, status=1/FAILURE
systemd[475]: psd-resync.service: Failed with result 'exit-code'.

The problem is trying to rm -rf the workdir of overlayfs, which only works if the root-owned index directory is empty.

On my system archlinux, Linux 5.9.2, kernel config:

CONFIG_OVERLAY_FS=m
CONFIG_OVERLAY_FS_REDIRECT_DIR=y
# CONFIG_OVERLAY_FS_REDIRECT_ALWAYS_FOLLOW is not set
CONFIG_OVERLAY_FS_INDEX=y
CONFIG_OVERLAY_FS_XINO_AUTO=y
CONFIG_OVERLAY_FS_METACOPY=y

index is not empty after deleting a file which is in the lower directory:

$mkdir lower upper work merged
$touch lower/f1
$sudo mount -t overlay overlaid -olowerdir=lower,upperdir=upper,workdir=work merged
$rm merged/f1
$sudo umount merged
$LANG=C rm -rf work
rm: cannot remove 'work/index': Permission denied
$sudo ls work/index
'#59a'
graysky2 commented 3 years ago

@Szunti - Good catch. One thought is to roll the rm -rf "$WORK" into the umount function within psd-overlay-helper to avoid this.

graysky2 commented 3 years ago

Thank you for digging into this.