attr: add in_group_or_capable()
authorChristian Brauner <brauner@kernel.org>
Mon, 17 Oct 2022 15:06:34 +0000 (17:06 +0200)
committerChristian Brauner (Microsoft) <brauner@kernel.org>
Tue, 18 Oct 2022 08:09:43 +0000 (10:09 +0200)
commit11c2a8700cdcabf9b639b7204a1e38e2a0b6798e
treef98a38095132d6d55b9f718ad07d3a3824998bdd
parent9abf2313adc1ca1b6180c508c25f22f9395cc780
attr: add in_group_or_capable()

In setattr_{copy,prepare}() we need to perform the same permission
checks to determine whether we need to drop the setgid bit or not.
Instead of open-coding it twice add a simple helper the encapsulates the
logic. We will reuse this helpers to make dropping the setgid bit during
write operations more consistent in a follow up patch.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
fs/attr.c
fs/inode.c
fs/internal.h