Skip to content

Commit 632be6f

Browse files
adam900710kdave
authored andcommitted
btrfs-progs: subvolume: fix a bug that leads to unnecessary error message
[BUG] When a btrfs is mounted with "user_subvol_rm_allowed" mount option, unprivileged users are allowed to delete a subvolume using "btrfs subvolume delete" command. But in that case, there is always a warning message: $ btrfs subvolume delete /mnt/btrfs/dir1/subv1/ WARNING: cannot read default subvolume id: Operation not permitted Delete subvolume 257 (no-commit): '/mnt/btrfs/dir1/subv1' [CAUSE] The warning message is caused by tree search ioctl, which is to determine if we're deleting the default subvolume. This search is just to give a more helpful error message, and even without it deleting the default subvolume will fail anyway. Thus commit 0e66228 ("btrfs-progs: subvol delete: hide a warning on an unprivileged delete") tries to hide the warning for unprivileged users. But unfortunately the function geteuid() returns the effective user id, thus we should hide the warning for non-zero uid, not the opposite. [FIX] Change the condition to output the warning only when the uid is 0. Reviewed-by: Boris Burkov <boris@bur.io> Signed-off-by: Qu Wenruo <wqu@suse.com>
1 parent 85ec48d commit 632be6f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmds/subvolume.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
498498
default_subvol_id = 0;
499499
err = btrfs_util_subvolume_get_default_fd(fd, &default_subvol_id);
500500
if (err == BTRFS_UTIL_ERROR_SEARCH_FAILED) {
501-
if (geteuid() != 0)
501+
if (geteuid() == 0)
502502
warning("cannot read default subvolume id: %m");
503503
}
504504

0 commit comments

Comments
 (0)