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>
This commit is contained in:
Christian Brauner 2022-10-17 17:06:34 +02:00 • committed by Christian Brauner (Microsoft)
commit 11c2a8700c
No known key found for this signature in database
GPG key ID: 91C61BC06578DCA2
3 changed files with 31 additions and 9 deletions