diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-10-08 11:06:08 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-10-08 11:06:08 -0400 |
commit | e55f1d1d13e7f1c364672d667d78fd1f640ab9f9 (patch) | |
tree | 406a3c127abb008f2f736c8d2ee03fc3c2926d6b /fs/posix_acl.c | |
parent | f334bcd94b7d3c0fbc34d518a86548f451ab5faf (diff) | |
parent | 030b533c4fd4d2ec3402363323de4bb2983c9cee (diff) |
Merge remote-tracking branch 'jk/vfs' into work.misc
Diffstat (limited to 'fs/posix_acl.c')
-rw-r--r-- | fs/posix_acl.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 87193924eb91..da3f760a7e88 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -627,6 +627,37 @@ err_release: } 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. */ |