andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.53k stars 177 forks source link

cannot trash regular file --btrfs subvolumes #311

Closed Tokariew closed 8 months ago

Tokariew commented 10 months ago

Describe the bug When trash folder is on btrfs subvolume diffrent than home i can't trash any file from my home folder

trash-cli version Output of: trash-put --version 0.23.2.13.2

Are you using the latest version of trash-cli? Yes

Have you tried if the bug is present in the latest version of trash-cli? Yes

Operating system:

To Reproduce

touch foo
trash-put foo

trash-put: cannot trash regular file foo

Expected behavior

I can trash files from any subvolume on my home partition

Volumes detail

➜ trash-list --debug-volumes
physical ->
[sdiskpart(device='/dev/mapper/luks-5996c2d8-9087-4003-a34f-442a9f40b77c', mountpoint='/media/nvme', fstype='btrfs', opts='rw,seclabel,nosuid,nodev,noatime,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/media', maxfile=255, maxpath=4096),
 sdiskpart(device='/dev/mapper/luks-69b27936-c5fe-4749-af6d-320bd26c125c', mountpoint='/run/media/tokariew/Backup2', fstype='btrfs', opts='rw,seclabel,nosuid,nodev,relatime,space_cache=v2,subvolid=5,subvol=/', maxfile=255, maxpath=4096),
 sdiskpart(device='/dev/mapper/luks-86287e1f-ff94-481a-9c72-091d618a75ab', mountpoint='/', fstype='btrfs', opts='rw,seclabel,relatime,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/root', maxfile=255, maxpath=4096),
 sdiskpart(device='/dev/mapper/luks-86287e1f-ff94-481a-9c72-091d618a75ab', mountpoint='/home', fstype='btrfs', opts='rw,seclabel,relatime,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/home', maxfile=255, maxpath=4096),
 sdiskpart(device='/dev/nvme0n1p1', mountpoint='/boot/efi', fstype='vfat', opts='rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro', maxfile=1530, maxpath=4096),
 sdiskpart(device='/dev/nvme0n1p2', mountpoint='/boot', fstype='ext4', opts='rw,seclabel,relatime', maxfile=255, maxpath=4096)]
virtual ->
[sdiskpart(device='192.168.0.113:/media/btrfs', mountpoint='/media/nfs', fstype='nfs4', opts='rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=14,retrans=2,sec=sys,clientaddr=192.168.0.111,local_lock=none,addr=192.168.0.113', maxfile=255, maxpath=4096),
 sdiskpart(device='binfmt_misc', mountpoint='/proc/sys/fs/binfmt_misc', fstype='binfmt_misc', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='bpf', mountpoint='/sys/fs/bpf', fstype='bpf', opts='rw,nosuid,nodev,noexec,relatime,mode=700', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup2', mountpoint='/sys/fs/cgroup', fstype='cgroup2', opts='rw,seclabel,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot', maxfile=255, maxpath=4096),
 sdiskpart(device='configfs', mountpoint='/sys/kernel/config', fstype='configfs', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='debugfs', mountpoint='/sys/kernel/debug', fstype='debugfs', opts='rw,seclabel,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='devpts', mountpoint='/dev/pts', fstype='devpts', opts='rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000', maxfile=255, maxpath=4096),
 sdiskpart(device='devtmpfs', mountpoint='/dev', fstype='devtmpfs', opts='rw,seclabel,nosuid,size=4096k,nr_inodes=4092164,mode=755,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='efivarfs', mountpoint='/sys/firmware/efi/efivars', fstype='efivarfs', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='fusectl', mountpoint='/sys/fs/fuse/connections', fstype='fusectl', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='hugetlbfs', mountpoint='/dev/hugepages', fstype='hugetlbfs', opts='rw,seclabel,relatime,pagesize=2M', maxfile=255, maxpath=4096),
 sdiskpart(device='mqueue', mountpoint='/dev/mqueue', fstype='mqueue', opts='rw,seclabel,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='portal', mountpoint='/run/user/1000/doc', fstype='fuse.portal', opts='rw,nosuid,nodev,relatime,user_id=1000,group_id=1000', maxfile=None, maxpath=4096),
 sdiskpart(device='proc', mountpoint='/proc', fstype='proc', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='pstore', mountpoint='/sys/fs/pstore', fstype='pstore', opts='rw,seclabel,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='ramfs', mountpoint='/run/credentials/systemd-vconsole-setup.service', fstype='ramfs', opts='ro,seclabel,nosuid,nodev,noexec,relatime,mode=700', maxfile=255, maxpath=4096),
 sdiskpart(device='ramfs', mountpoint='/run/credentials/systemd-sysctl.service', fstype='ramfs', opts='ro,seclabel,nosuid,nodev,noexec,relatime,mode=700', maxfile=255, maxpath=4096),
 sdiskpart(device='ramfs', mountpoint='/run/credentials/systemd-tmpfiles-setup-dev.service', fstype='ramfs', opts='ro,seclabel,nosuid,nodev,noexec,relatime,mode=700', maxfile=255, maxpath=4096),
 sdiskpart(device='ramfs', mountpoint='/run/credentials/systemd-tmpfiles-setup.service', fstype='ramfs', opts='ro,seclabel,nosuid,nodev,noexec,relatime,mode=700', maxfile=255, maxpath=4096),
 sdiskpart(device='ramfs', mountpoint='/run/credentials/systemd-resolved.service', fstype='ramfs', opts='ro,seclabel,nosuid,nodev,noexec,relatime,mode=700', maxfile=255, maxpath=4096),
 sdiskpart(device='securityfs', mountpoint='/sys/kernel/security', fstype='securityfs', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='selinuxfs', mountpoint='/sys/fs/selinux', fstype='selinuxfs', opts='rw,nosuid,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='sunrpc', mountpoint='/var/lib/nfs/rpc_pipefs', fstype='rpc_pipefs', opts='rw,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='sysfs', mountpoint='/sys', fstype='sysfs', opts='rw,seclabel,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='systemd-1', mountpoint='/proc/sys/fs/binfmt_misc', fstype='autofs', opts='rw,relatime,fd=35,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=24820', maxfile=255, maxpath=4096),
 sdiskpart(device='systemd-1', mountpoint='/media/nfs', fstype='autofs', opts='rw,relatime,fd=41,pgrp=1,timeout=60,minproto=5,maxproto=5,direct,pipe_ino=22711', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/dev/shm', fstype='tmpfs', opts='rw,seclabel,nosuid,nodev,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run', fstype='tmpfs', opts='rw,seclabel,nosuid,nodev,size=6553128k,nr_inodes=819200,mode=755,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/tmp', fstype='tmpfs', opts='rw,seclabel,nosuid,nodev,nr_inodes=1048576,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run/user/1000', fstype='tmpfs', opts='rw,seclabel,nosuid,nodev,relatime,size=3276564k,nr_inodes=819141,mode=700,uid=1000,gid=1000,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run/firejail/dbus', fstype='tmpfs', opts='rw,seclabel,nosuid,nodev,noexec,size=6553128k,nr_inodes=819200,mode=755,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run/firejail/firejail.ro.dir', fstype='tmpfs', opts='ro,seclabel,nosuid,nodev,size=6553128k,nr_inodes=819200,mode=755,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run/firejail/firejail.ro.file', fstype='tmpfs', opts='ro,seclabel,nosuid,nodev,size=6553128k,nr_inodes=819200,mode=755,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tracefs', mountpoint='/sys/kernel/tracing', fstype='tracefs', opts='rw,seclabel,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096)]
Filesystem                 1024-blocks        Used  Available Capacity Mounted on
devtmpfs                          4096           0       4096       0% /dev
tmpfs                         16382820      413136   15969684       3% /dev/shm
tmpfs                          6553128        1428    6551700       1% /run
/dev/dm-0                    975081472   201467440  764843344      21% /
/dev/dm-0                    975081472   201467440  764843344      21% /home
tmpfs                         16382820       19080   16363740       1% /tmp
/dev/nvme0n1p2                  996780      219412     708556      24% /boot
/dev/nvme0n1p1                  613184        7196     605988       2% /boot/efi
/dev/dm-1                   2000382296  1140482724  856438332      58% /media/nvme
tmpfs                          3276564       38852    3237712       2% /run/user/1000
/dev/dm-2                    732558200   516048328  216310008      71% /run/media/tokariew/Backup2
192.168.0.113:/media/btrfs 15628075008 10367247360 1359199232      89% /media/nfs

➜ sudo btrfs subvolume list . | grep --color=auto -v snapshot ID 256 gen 156594 top level 5 path home ID 257 gen 156593 top level 5 path root ID 258 gen 155393 top level 257 path root/var/lib/portables ID 259 gen 155393 top level 257 path root/var/lib/machines ID 260 gen 156593 top level 256 path tokariew/Games ID 261 gen 156461 top level 256 path tokariew/tmp ID 262 gen 156594 top level 256 path tokariew/.local ID 263 gen 156594 top level 256 path tokariew/.config ID 264 gen 156586 top level 256 path tokariew/.cache ID 275 gen 156461 top level 262 path tokariew/.local/share/libvirt/images

maybe related too: https://github.com/andreafrancia/trash-cli/issues/247

Sorry, for create nerly empty issue, and then editing, little keyboard error

Tokariew commented 10 months ago
✗  trash-put --verbose README.md
trash-put: volume of file: /home
trash-put: trying trash dir: /home/tokariew/.local/share/Trash from volume: /home/tokariew/.local
trash-put: won't use trash dir ~/.local/share/Trash because its volume (/home/tokariew/.local) in a different volume than README.md (/home)
trash-put: found unusable .Trash dir (should be a dir): /home/.Trash
trash-put: trash directory is not secure: /home/.Trash/1000
trash-put: trying trash dir: /home/.Trash-1000 from volume: /home
trash-put: failed to trash README.md in /home/.Trash-1000, because: [Errno 13] Permission denied: '/home/.Trash-1000'
trash-put: cannot trash regular file 'README.md'
andreafrancia commented 8 months ago

Thank for your reporting. At the moment BTRFS is not supported because I don't know how it works and, right now I don't have free time to investigate how trash-cli should adapt to interact with it.

You can try the untested and hidden --home-fallback feature that I mentioned here: https://github.com/andreafrancia/trash-cli/issues/300#issuecomment-1786065185