btrfs-progs icon indicating copy to clipboard operation
btrfs-progs copied to clipboard

RFE, Remove warning when deleting subvolume as a regular user with `user_subvol_rm_allowed`

Open cvlc12 opened this issue 8 months ago • 4 comments

Hi,

When deleting a subvol as a regular user with user_subvol_rm_allowed (See https://github.com/kdave/btrfs-progs/issues/252), a confusing WARNING is printed, even though the subvolume is properly deleted.

$ btrfs subvolume create bob
$ btrfs subvolume delete bob
WARNING: cannot read default subvolume id: Operation not permitted
Delete subvolume 332 (no-commit): '/home/user/Projets/Sandbox/bob'

Is is really necessary to print this warning ?

Have a good day

cvlc12 avatar Apr 05 '25 09:04 cvlc12

The default subvolume cannot be deleted and both userspace and kernel do the check. It's there to distinguish the "what you want to delete is possible but forbidden because it's default subvolume" and "you cannot delete the subvolume due to permissions". Even with user_subvol_rm_allowed you may not be able to delete the subvolume and it's not outright clear why. So if the warning explains that, I think it could stay. What do you think about that?

kdave avatar Apr 06 '25 23:04 kdave

I think we should improve the message, so that if the deletion is an unprivileged one, we should not output that error message, or improve it to something like "unable to determine the default subvolume, skipping".

As if later it turns out to be the default one, kernel will reject it anyway.

adam900710 avatar Apr 06 '25 23:04 adam900710

The default subvolume cannot be deleted and both userspace and kernel do the check. It's there to distinguish the "what you want to delete is possible but forbidden because it's default subvolume" and "you cannot delete the subvolume due to permissions". Even with user_subvol_rm_allowed you may not be able to delete the subvolume and it's not outright clear why. So if the warning explains that, I think it could stay. What do you think about that?

Hmm, I'm confused, I'm not trying to delete the default subvolume at all.

Just create a random subvolume as a regular user, then try to delete it. With user_subvol_rm_allowed set, the subvolume is properly deleted, but a confusing warning is printed.

cvlc12 avatar Apr 07 '25 08:04 cvlc12

As a side note, shouldn't $ btrfs subvolume list /home/user work as a normal user? At least with user_subvol_rm_allowed set?

Does it make sense that a user can delete subvolumes, but not list them?

$ btrfs subvolume list /home/user
ERROR: can't perform the search: Operation not permitted

cvlc12 avatar Apr 07 '25 08:04 cvlc12

Fixed in 6.16 with https://github.com/kdave/btrfs-progs/commit/47caea649f52ed0aef53fd8fcb0f8f294ba6c1f4

cvlc12 avatar Aug 29 '25 18:08 cvlc12