mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 21:15:53 +02:00
posix_acl: Clear SGID bit when setting file permissions
Cherry-pick to f2fs only for generic/375 from: (073931017: posix_acl: Clear SGID bit when setting file permissions) Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
a1561fae1b
commit
2ca2001b3a
|
|
@ -215,12 +215,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
|
|||
case ACL_TYPE_ACCESS:
|
||||
name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
|
||||
if (acl) {
|
||||
error = posix_acl_equiv_mode(acl, &inode->i_mode);
|
||||
if (error < 0)
|
||||
error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
|
||||
if (error)
|
||||
return error;
|
||||
set_acl_inode(inode, inode->i_mode);
|
||||
if (error == 0)
|
||||
acl = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -592,6 +592,37 @@ posix_acl_create(struct inode *dir, umode_t *mode,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(posix_acl_create);
|
||||
|
||||
/**
|
||||
* posix_acl_update_mode - update mode in set_acl
|
||||
*
|
||||
* Update the file mode when setting an ACL: compute the new file permission
|
||||
* bits based on the ACL. In addition, if the ACL is equivalent to the new
|
||||
* file mode, set *acl to NULL to indicate that no ACL should be set.
|
||||
*
|
||||
* As with chmod, clear the setgit bit if the caller is not in the owning group
|
||||
* or capable of CAP_FSETID (see inode_change_ok).
|
||||
*
|
||||
* Called from set_acl inode operations.
|
||||
*/
|
||||
int posix_acl_update_mode(struct inode *inode, umode_t *mode_p,
|
||||
struct posix_acl **acl)
|
||||
{
|
||||
umode_t mode = inode->i_mode;
|
||||
int error;
|
||||
|
||||
error = posix_acl_equiv_mode(*acl, &mode);
|
||||
if (error < 0)
|
||||
return error;
|
||||
if (error == 0)
|
||||
*acl = NULL;
|
||||
if (!in_group_p(inode->i_gid) &&
|
||||
!capable_wrt_inode_uidgid(inode, CAP_FSETID))
|
||||
mode &= ~S_ISGID;
|
||||
*mode_p = mode;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(posix_acl_update_mode);
|
||||
|
||||
/*
|
||||
* Fix up the uids and gids in posix acl extended attributes in place.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ extern int set_posix_acl(struct inode *, int, struct posix_acl *);
|
|||
extern int posix_acl_chmod(struct inode *, umode_t);
|
||||
extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
|
||||
struct posix_acl **);
|
||||
extern int posix_acl_update_mode(struct inode *, umode_t *, struct posix_acl **);
|
||||
|
||||
extern int simple_set_acl(struct inode *, struct posix_acl *, int);
|
||||
extern int simple_acl_create(struct inode *, struct inode *);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user