Skip to contentSkip to conversation

btrfs-progs: subv del: hide a bogus warning on an unprivileged delete

PATCH In review Adam Borowski 2 participants 2 messages Jan 24, 2022 – Feb 1, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: subv del: hide a bogus 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 87804a3f0663a4d1891395bd97b8e81e6f183e66
Ref: https://bugs.debian.org/998840

---
 cmds/subvolume.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cmds/subvolume.c +2 -1
index 6aac7dd1..e767e20d 100644
@@ -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())
+			warning("cannot read default subvolume id: %m");
 		default_subvol_id = 0;
 	}
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 10 lines · Adam Borowski

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 87804a3f0663a4d1891395bd97b8e81e6f183e66
Ref: https://bugs.debian.org/998840

Thanks, added to devel, that covers the part when the search fails. It could also fail when the default subvolume is not set so I might add a separate check for that.