btrfs-progs: subvol delete: hide a warning on an unprivileged delete

Checking the default subvolume uses TREE_SEARCH which is a CAP_SYS_ADMIN
only operation, and thus will fail when unprivileged, even if we have
permissions to actually delete the subvolume.

This produces a warning even if all is ok.  Let's hide it if we're not
root (root but !CAP is odd enough to warn).

Fixes 87804a3f06 ("btrfs-progs: subvolume: check deleting default subvolume")
Link: https://bugs.debian.org/998840
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Adam Borowski 2022-01-24 14:36:32 +01:00 committed by David Sterba
parent f77da2b173
commit 0e66228959
1 changed files with 2 additions and 1 deletions

View File

@ -376,7 +376,8 @@ again:
err = btrfs_util_get_default_subvolume_fd(fd, &default_subvol_id);
if (err) {
warning("cannot read default subvolume id: %m");
if (geteuid() != 0)
warning("cannot read default subvolume id: %m");
default_subvol_id = 0;
}