mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
f2fs: Use in_group_or_capable() helper
Use the in_group_or_capable() helper function to simplify the code. Signed-off-by: Youling Tang <tangyouling@kylinos.cn> Link: https://lore.kernel.org/r/20240620032335.147136-2-youling.tang@linux.dev Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
9b6a14f08b
commit
8444ee22ad
@ -219,8 +219,7 @@ static int f2fs_acl_update_mode(struct mnt_idmap *idmap,
|
|||||||
return error;
|
return error;
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
*acl = NULL;
|
*acl = NULL;
|
||||||
if (!vfsgid_in_group_p(i_gid_into_vfsgid(idmap, inode)) &&
|
if (!in_group_or_capable(idmap, inode, i_gid_into_vfsgid(idmap, inode)))
|
||||||
!capable_wrt_inode_uidgid(idmap, inode, CAP_FSETID))
|
|
||||||
mode &= ~S_ISGID;
|
mode &= ~S_ISGID;
|
||||||
*mode_p = mode;
|
*mode_p = mode;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -923,10 +923,8 @@ static void __setattr_copy(struct mnt_idmap *idmap,
|
|||||||
inode_set_ctime_to_ts(inode, attr->ia_ctime);
|
inode_set_ctime_to_ts(inode, attr->ia_ctime);
|
||||||
if (ia_valid & ATTR_MODE) {
|
if (ia_valid & ATTR_MODE) {
|
||||||
umode_t mode = attr->ia_mode;
|
umode_t mode = attr->ia_mode;
|
||||||
vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
|
|
||||||
|
|
||||||
if (!vfsgid_in_group_p(vfsgid) &&
|
if (!in_group_or_capable(idmap, inode, i_gid_into_vfsgid(idmap, inode)))
|
||||||
!capable_wrt_inode_uidgid(idmap, inode, CAP_FSETID))
|
|
||||||
mode &= ~S_ISGID;
|
mode &= ~S_ISGID;
|
||||||
set_acl_inode(inode, mode);
|
set_acl_inode(inode, mode);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user